Skip to content

Commit 3da286f

Browse files
committed
Fix: Update syntax of graphviz-webcomponent.
Correctly translate graphviz-webcomponent from Client to source code.
1 parent 6200c06 commit 3da286f

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ following characters should be escaped: `*`, `_`, `\`, `[`, `]`, `<`.
147147
The CodeChat Editor contains rudimentary support for diagrams created by
148148
[Graphviz](https://graphviz.org/). For example,
149149

150-
| Source | Rendered |
151-
| -------------------------------------------------------------- | ------------------------------------------------------------ |
152-
| `<graphviz-graph graph="digraph { A -> B }"></graphviz-graph>` | <graphviz-graph graph="digraph { A -> B }"></graphviz-graph> |
150+
| Source | Rendered |
151+
| ----------------------------------------------------- | --------------------------------------------------- |
152+
| `<graphviz-graph>digraph { A -> B }</graphviz-graph>` | <graphviz-graph>digraph { A -> B }</graphviz-graph> |
153153

154154
To edit these diagrams, use an [HTML entity
155155
encoder/decoder](https://mothereff.in/html-entities) and a Graphviz editor such

client/package.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
'@codemirror/view': '^6.38.2',
6363
'@mathjax/mathjax-newcm-font': '4.0.0',
6464
codemirror: '^6.0.2',
65-
'graphviz-webcomponent': '^2.0.0',
65+
'graphviz-webcomponent': 'github:bjones1/graphviz-webcomponent#dist',
6666
mathjax: '4.0.0',
6767
mermaid: '^11.10.1',
6868
'npm-check-updates': '^18.0.3',

client/src/third-party/turndown/turndown.browser.es.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ var meaningfulWhenBlankElements = [
5555
];
5656

5757
function isMeaningfulWhenBlank (node) {
58-
return is(node, meaningfulWhenBlankElements)
58+
// Certain standard HTML tags, plus any custom tag, are meaningful when blank.
59+
return is(node, meaningfulWhenBlankElements) || node.nodeName.includes('-')
5960
}
6061

6162
function hasMeaningfulWhenBlank (node) {
@@ -77,7 +78,7 @@ function has (node, tagNames) {
7778

7879
function Node (node, options) {
7980
node.isBlock = isBlock(node);
80-
node.isCode = node.nodeName === 'CODE' || node.nodeName === 'WC-MERMAID' || node.parentNode.isCode;
81+
node.isCode = node.nodeName === 'CODE' || node.nodeName === 'WC-MERMAID' || node.nodeName === 'GRAPHVIZ-GRAPH' || node.parentNode.isCode;
8182
node.isBlank = isBlank(node);
8283
node.flankingWhitespace = flankingWhitespace(node, options);
8384
// When true, this node will be rendered as pure Markdown; false indicates it
@@ -132,7 +133,8 @@ function isBlank (node) {
132133
!isMeaningfulWhenBlank(node) &&
133134
/^\s*$/i.test(node.textContent) &&
134135
!hasVoid(node) &&
135-
!hasMeaningfulWhenBlank(node)
136+
!hasMeaningfulWhenBlank(node) &&
137+
(node.childNodes === undefined || node.childNodes.length === 0)
136138
)
137139
}
138140

@@ -773,7 +775,7 @@ function collapseWhitespace (options) {
773775
var isBlock = options.isBlock;
774776
var isVoid = options.isVoid;
775777
var isPre = options.isPre || function (node) {
776-
return node.nodeName === 'PRE' || node.nodeName === 'WC-MERMAID'
778+
return node.nodeName === 'PRE' || node.nodeName === 'WC-MERMAID' || node.nodeName === 'GRAPHVIZ-GRAPH'
777779
};
778780
var renderAsPure = options.renderAsPure;
779781

@@ -1222,7 +1224,7 @@ TurndownService.prototype = {
12221224

12231225
// These HTML elements are considered block nodes, as opposed to inline nodes. It's based on the Commonmark spec's selection of [HTML blocks](https://spec.commonmark.org/0.31.2/#html-blocks).
12241226
const blockNodeNames = new Set([
1225-
'PRE', 'SCRIPT', 'STYLE', 'TEXTAREA', 'ADDRESS', 'ARTICLE', 'ASIDE', 'BASE', 'BASEFONT', 'BLOCKQUOTE', 'BODY', 'CAPTION', 'CENTER', 'COL', 'COLGROUP', 'DD', 'DETAILS', 'DIALOG', 'DIR', 'DIV', 'DL', 'DT', 'FIELDSET', 'FIGCAPTION', 'FIGURE', 'FOOTER', 'FORM', 'FRAME', 'FRAMESET', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HEAD', 'HEADER', 'HR', 'HTML', 'IFRAME', 'LEGEND', 'LI', 'LINK', 'MAIN', 'MENU', 'MENUITEM', 'NAV', 'NOFRAMES', 'OL', 'OPTGROUP', 'OPTION', 'P', 'PARAM', 'SEARCH', 'SECTION', 'SUMMARY', 'TABLE', 'TBODY', 'TD', 'TFOOT', 'TH', 'THEAD', 'TITLE', 'TR', 'TRACK', 'UL', 'WC-MERMAID'
1227+
'PRE', 'SCRIPT', 'STYLE', 'TEXTAREA', 'ADDRESS', 'ARTICLE', 'ASIDE', 'BASE', 'BASEFONT', 'BLOCKQUOTE', 'BODY', 'CAPTION', 'CENTER', 'COL', 'COLGROUP', 'DD', 'DETAILS', 'DIALOG', 'DIR', 'DIV', 'DL', 'DT', 'FIELDSET', 'FIGCAPTION', 'FIGURE', 'FOOTER', 'FORM', 'FRAME', 'FRAMESET', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HEAD', 'HEADER', 'HR', 'HTML', 'IFRAME', 'LEGEND', 'LI', 'LINK', 'MAIN', 'MENU', 'MENUITEM', 'NAV', 'NOFRAMES', 'OL', 'OPTGROUP', 'OPTION', 'P', 'PARAM', 'SEARCH', 'SECTION', 'SUMMARY', 'TABLE', 'TBODY', 'TD', 'TFOOT', 'TH', 'THEAD', 'TITLE', 'TR', 'TRACK', 'UL', 'WC-MERMAID', 'GRAPHVIZ-GRAPH'
12261228
]);
12271229

12281230
/**

0 commit comments

Comments
 (0)