diff --git a/src/wireviz/Harness.py b/src/wireviz/Harness.py
index af7946e3..6a0d5bfa 100644
--- a/src/wireviz/Harness.py
+++ b/src/wireviz/Harness.py
@@ -8,7 +8,7 @@
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, \
nested_html_table, flatten2d, index_if_list, html_line_breaks, \
graphviz_line_breaks, remove_line_breaks, open_file_read, open_file_write, \
- manufacturer_info_field
+ manufacturer_info_field, remove_links
from collections import Counter
from typing import List
from pathlib import Path
@@ -90,8 +90,8 @@ def create_graph(self) -> Graph:
html = []
- rows = [[connector.name if connector.show_name else None],
- [f'P/N: {connector.pn}' if connector.pn else None,
+ rows = [[remove_links(connector.name) if connector.show_name else None],
+ [f'P/N: {remove_links(connector.pn)}' if connector.pn else None,
html_line_breaks(manufacturer_info_field(connector.manufacturer, connector.mpn))],
[html_line_breaks(connector.type),
html_line_breaks(connector.subtype),
@@ -161,8 +161,8 @@ def create_graph(self) -> Graph:
elif cable.gauge_unit.upper() == 'AWG':
awg_fmt = f' ({mm2_equiv(cable.gauge)} mm\u00B2)'
- rows = [[cable.name if cable.show_name else None],
- [f'P/N: {cable.pn}' if (cable.pn and not isinstance(cable.pn, list)) else None,
+ rows = [[remove_links(cable.name) if cable.show_name else None],
+ [f'P/N: {remove_links(cable.pn)}' if (cable.pn and not isinstance(cable.pn, list)) else None,
html_line_breaks(manufacturer_info_field(
cable.manufacturer if not isinstance(cable.manufacturer, list) else None,
cable.mpn if not isinstance(cable.mpn, list) else None))],
@@ -204,10 +204,10 @@ def create_graph(self) -> Graph:
# create a list of wire parameters
wireidentification = []
if isinstance(cable.pn, list):
- wireidentification.append(f'P/N: {cable.pn[i - 1]}')
+ wireidentification.append(f'P/N: {remove_links(cable.pn[i - 1])}')
manufacturer_info = manufacturer_info_field(
- cable.manufacturer[i - 1] if isinstance(cable.manufacturer, list) else None,
- cable.mpn[i - 1] if isinstance(cable.mpn, list) else None)
+ remove_links(cable.manufacturer[i - 1]) if isinstance(cable.manufacturer, list) else None,
+ remove_links(cable.mpn[i - 1]) if isinstance(cable.mpn, list) else None)
if manufacturer_info:
wireidentification.append(html_line_breaks(manufacturer_info))
# print parameters into a table row under the wire
diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py
index 418060d2..788639f7 100644
--- a/src/wireviz/wv_helper.py
+++ b/src/wireviz/wv_helper.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from typing import List
+import re
awg_equiv_table = {
'0.09': '28',
@@ -106,15 +107,18 @@ def tuplelist2tsv(inp, header=None):
inp.insert(0, header)
inp = flatten2d(inp)
for row in inp:
- output = output + '\t'.join(str(item) for item in row) + '\n'
+ output = output + '\t'.join(str(remove_links(item)) for item in row) + '\n'
return output
# Return the value indexed if it is a list, or simply the value otherwise.
def index_if_list(value, index):
return value[index] if isinstance(value, list) else value
+def remove_links(inp):
+ return re.sub(r'<[aA] [^>]*>([^<]*)[aA]>', r'\1', inp) if isinstance(inp, str) else inp
+
def html_line_breaks(inp):
- return inp.replace('\n', '
') if isinstance(inp, str) else inp
+ return remove_links(inp).replace('\n', '
') if isinstance(inp, str) else inp
def graphviz_line_breaks(inp):
return inp.replace('\n', '\\n') if isinstance(inp, str) else inp # \n generates centered new lines. http://www.graphviz.org/doc/info/attrs.html#k:escString