diff --git a/build/build-termlist.py b/build/build-termlist.py index cbd29b3..a82d0d9 100644 --- a/build/build-termlist.py +++ b/build/build-termlist.py @@ -57,7 +57,7 @@ display_id = ['record_level', 'dc', 'dcterms', 'occurrence', 'organism', 'materi # --------------- # replace URL with link (function used with Audubon Core list of terms build script) -# Does not correctly handle URLs with close parens ) characters. +# Does not correctly handle URLs with close parens ) characters, so no longer used. # def createLinks(text): def repl(match): @@ -69,15 +69,13 @@ def createLinks(text): result = re.sub(pattern, repl, text) return result -# 2021-08-05 Replace the createLinks() function with functions copied from the QRG build script written by S. Van Hoey +# 2021-08-06 Replace the createLinks() function with functions copied from the QRG build script written by S. Van Hoey def convert_code(text_with_backticks): """Takes all back-quoted sections in a text field and converts it to the html tagged version of code blocks ... """ return re.sub(r'`([^`]*)`', r'\1', text_with_backticks) -# 2021-08-06 Discovered when using this with Audubon Core list of terms build script that it does not -# correctly handle trailing commas that follow a URL. I don't understand the regex well enough to fix it def convert_link(text_with_urls): """Takes all links in a text field and converts it to the html tagged version of the link @@ -87,7 +85,7 @@ def convert_link(text_with_urls): url = inputstring.group() return "{}".format(url, url) - regx = "(http[s]?://[\w\d:#@%/;$()~_?\+-;=\\\.&]*)(?{}".format(url, url) - regx = "(http[s]?://[\w\d:#@%/;$()~_?\+-;=\\\.&]*)(?...\n", + " \"\"\"\n", + " return re.sub(r'`([^`]*)`', r'\\1', text_with_backticks)\n", + "\n", + "def convert_link(text_with_urls):\n", + " \"\"\"Takes all links in a text field and converts it to the html tagged\n", + " version of the link\n", + " \"\"\"\n", + " def _handle_matched(inputstring):\n", + " \"\"\"quick hack version of url handling on the current prime versions data\"\"\"\n", + " url = inputstring.group()\n", + " return \"{}\".format(url, url)\n", + "\n", + " regx = \"(http[s]?://[\\w\\d:#@%/;$()~_?\\+-;=\\\\\\.&]*)(?\\n'\n", " text += '\\t\\t\\tUsage\\n'\n", - " text += '\\t\\t\\t' + createLinks(row['usage']) + '\\n'\n", + " text += '\\t\\t\\t' + convert_link(convert_code(row['usage'])) + '\\n'\n", " text += '\\t\\t\\n'\n", "\n", " if row['notes'] != '':\n", " text += '\\t\\t\\n'\n", " text += '\\t\\t\\tNotes\\n'\n", - " text += '\\t\\t\\t' + createLinks(row['notes']) + '\\n'\n", + " text += '\\t\\t\\t' + convert_link(convert_code(row['notes'])) + '\\n'\n", " text += '\\t\\t\\n'\n", "\n", " if (vocab_type == 2 or vocab_type == 3) and row['controlled_value_string'] != '': # controlled vocabulary\n", @@ -416,7 +435,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.1" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/build/em-cv-build/build-page-simple.ipynb b/build/em-cv-build/build-page-simple.ipynb index afc54e9..96d0f3c 100644 --- a/build/em-cv-build/build-page-simple.ipynb +++ b/build/em-cv-build/build-page-simple.ipynb @@ -65,7 +65,26 @@ "\n", " pattern = '(https?://[^\\s,;\\)\"]*)'\n", " result = re.sub(pattern, repl, text)\n", - " return result" + " return result\n", + "\n", + "# 2021-08-06 Replace the createLinks() function with functions copied from the QRG build script written by S. Van Hoey\n", + "def convert_code(text_with_backticks):\n", + " \"\"\"Takes all back-quoted sections in a text field and converts it to\n", + " the html tagged version of code blocks ...\n", + " \"\"\"\n", + " return re.sub(r'`([^`]*)`', r'\\1', text_with_backticks)\n", + "\n", + "def convert_link(text_with_urls):\n", + " \"\"\"Takes all links in a text field and converts it to the html tagged\n", + " version of the link\n", + " \"\"\"\n", + " def _handle_matched(inputstring):\n", + " \"\"\"quick hack version of url handling on the current prime versions data\"\"\"\n", + " url = inputstring.group()\n", + " return \"{}\".format(url, url)\n", + "\n", + " regx = \"(http[s]?://[\\w\\d:#@%/;$()~_?\\+-;=\\\\\\.&]*)(?\\n'\n", " text += '\\t\\t\\tUsage\\n'\n", - " text += '\\t\\t\\t' + createLinks(row['usage']) + '\\n'\n", + " text += '\\t\\t\\t' + convert_link(convert_code(row['usage'])) + '\\n'\n", " text += '\\t\\t\\n'\n", "\n", " if row['notes'] != '':\n", " text += '\\t\\t\\n'\n", " text += '\\t\\t\\tNotes\\n'\n", - " text += '\\t\\t\\t' + createLinks(row['notes']) + '\\n'\n", + " text += '\\t\\t\\t' + convert_link(convert_code(row['notes'])) + '\\n'\n", " text += '\\t\\t\\n'\n", "\n", " if (vocab_type == 2 or vocab_type == 3) and row['controlled_value_string'] != '': # controlled vocabulary\n", @@ -416,7 +435,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.1" + "version": "3.8.5" } }, "nbformat": 4, diff --git a/build/pw-cv-build/build-page-simple.ipynb b/build/pw-cv-build/build-page-simple.ipynb index 199d857..796acb7 100644 --- a/build/pw-cv-build/build-page-simple.ipynb +++ b/build/pw-cv-build/build-page-simple.ipynb @@ -65,7 +65,26 @@ "\n", " pattern = '(https?://[^\\s,;\\)\"]*)'\n", " result = re.sub(pattern, repl, text)\n", - " return result" + " return result\n", + "\n", + "# 2021-08-06 Replace the createLinks() function with functions copied from the QRG build script written by S. Van Hoey\n", + "def convert_code(text_with_backticks):\n", + " \"\"\"Takes all back-quoted sections in a text field and converts it to\n", + " the html tagged version of code blocks ...\n", + " \"\"\"\n", + " return re.sub(r'`([^`]*)`', r'\\1', text_with_backticks)\n", + "\n", + "def convert_link(text_with_urls):\n", + " \"\"\"Takes all links in a text field and converts it to the html tagged\n", + " version of the link\n", + " \"\"\"\n", + " def _handle_matched(inputstring):\n", + " \"\"\"quick hack version of url handling on the current prime versions data\"\"\"\n", + " url = inputstring.group()\n", + " return \"{}\".format(url, url)\n", + "\n", + " regx = \"(http[s]?://[\\w\\d:#@%/;$()~_?\\+-;=\\\\\\.&]*)(?\\n'\n", " text += '\\t\\t\\tUsage\\n'\n", - " text += '\\t\\t\\t' + createLinks(row['usage']) + '\\n'\n", + " text += '\\t\\t\\t' + convert_link(convert_code(row['usage'])) + '\\n'\n", " text += '\\t\\t\\n'\n", "\n", " if row['notes'] != '':\n", " text += '\\t\\t\\n'\n", " text += '\\t\\t\\tNotes\\n'\n", - " text += '\\t\\t\\t' + createLinks(row['notes']) + '\\n'\n", + " text += '\\t\\t\\t' + convert_link(convert_code(row['notes'])) + '\\n'\n", " text += '\\t\\t\\n'\n", "\n", " if (vocab_type == 2 or vocab_type == 3) and row['controlled_value_string'] != '': # controlled vocabulary\n", @@ -416,7 +435,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.1" + "version": "3.8.5" } }, "nbformat": 4,