Skip to content

Commit

Permalink
decode footnote text
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson committed Mar 8, 2016
1 parent b058cf3 commit 7635124
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
9 changes: 4 additions & 5 deletions dist/markdown-it-synapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function synapse(state, silent) {
max = state.posMax,
start = state.pos,
widgetParams,
decodedWidgetParams,
matchResults,
footnoteText,
widgetContainerClass = 'widgetContainer';
Expand Down Expand Up @@ -54,11 +55,12 @@ function synapse(state, silent) {
token = state.push('synapse_reference_close', 'span', -1);
// also push bookmark markdown into the environment variable
// (will be reprocessed and appended to the html output from the first pass)
matchResults = TEXT_PARAM_RE.exec(widgetParams);
decodedWidgetParams = decodeURIComponent(widgetParams);
matchResults = TEXT_PARAM_RE.exec(decodedWidgetParams);
if (matchResults) {
footnoteText = matchResults[1];
footnotes += '${bookmark?text=[' + footnoteId +
']&bookmarkID=wikiReference' + footnoteId + '} ' + decodeURIComponent(footnoteText) + '\n\n';
']&bookmarkID=wikiReference' + footnoteId + '} ' + footnoteText + '\n';
}
footnoteId++;
widgetContainerClass = 'inlineWidgetContainer';
Expand All @@ -68,9 +70,6 @@ function synapse(state, silent) {
token.attrs = [ [ 'id', 'wikiFootnote' + footnoteId ] ];
token = state.push('synapse_footnote_target_close', 'span', -1);

token = state.push('synapse_footnote_target_newline_open', 'br', 1);
token = state.push('synapse_footnote_target_newline_close', 'br', -1);

footnoteId++;
widgetContainerClass = 'inlineWidgetContainer';
}
Expand Down
2 changes: 1 addition & 1 deletion dist/markdown-it-synapse.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function synapse(state, silent) {
max = state.posMax,
start = state.pos,
widgetParams,
decodedWidgetParams,
matchResults,
footnoteText,
widgetContainerClass = 'widgetContainer';
Expand Down Expand Up @@ -53,11 +54,12 @@ function synapse(state, silent) {
token = state.push('synapse_reference_close', 'span', -1);
// also push bookmark markdown into the environment variable
// (will be reprocessed and appended to the html output from the first pass)
matchResults = TEXT_PARAM_RE.exec(widgetParams);
decodedWidgetParams = decodeURIComponent(widgetParams);
matchResults = TEXT_PARAM_RE.exec(decodedWidgetParams);
if (matchResults) {
footnoteText = matchResults[1];
footnotes += '${bookmark?text=[' + footnoteId +
']&bookmarkID=wikiReference' + footnoteId + '} ' + decodeURIComponent(footnoteText) + '\n\n';
']&bookmarkID=wikiReference' + footnoteId + '} ' + footnoteText + '\n';
}
footnoteId++;
widgetContainerClass = 'inlineWidgetContainer';
Expand All @@ -67,9 +69,6 @@ function synapse(state, silent) {
token.attrs = [ [ 'id', 'wikiFootnote' + footnoteId ] ];
token = state.push('synapse_footnote_target_close', 'span', -1);

token = state.push('synapse_footnote_target_newline_open', 'br', 1);
token = state.push('synapse_footnote_target_newline_close', 'br', -1);

footnoteId++;
widgetContainerClass = 'inlineWidgetContainer';
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/synapse.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This is a ref ${reference?inlineWidget=true&text=K%2EA%2E Hoadley%2C C%2E Yau%2C
.
${bookmark?text=[1]&inlineWidget=true&bookmarkID=wikiReference1} K%2EA%2E Hoadley%2C C%2E Yau%2C D%2EM%2E Wolf%2C A%2ED%2E Cherniack%2C D%2E Tamborero%2C S%2E Ng%2C M%2ED%2EM%2E Leiserson%2C B%2E Niu%2C M%2ED%2E McLellan%2C V%2E Uzunangelov%2C J%2E Zhang%2C C%2E Kandoth%2C R%2E Akbani%2C H%2E Shen%2C L%2E Omberg%2C A%2E Chu%2C A%2EA%2E Margolin%2C L%2EJ%2E van’t Veer%2C N%2E Lopez%2DBigas%2C P%2EW%2E Laird%2C B%2EJ%2E Raphael%2C L%2E Ding%2C A%2EG%2E Robertson%2C L%2EA%2E Byers%2C G%2EB%2E Mills%2C J%2EN%2E Weinstein%2C C%2E Van Waes%2C Z%2E Chen%2C E%2EA%2E Collisson%2C The Cancer Genome Atlas Research Network%2C C%2EC%2E Benz%2C C%2EM%2E Perou%2C and J%2EM%2E Stuart %282014%29%2E Multiplatform Analysis of 12 Cancer Types Reveals Molecular Classification within and across Tissues of Origin%2E Cell 158%2E http%3A%2F%2Fdx%2Edoi%2Eorg%2F10%2E1016%2Fj%2Ecell%2E2014%2E06%2E049
.
<p><span id="wikiFootnote2"></span><br></br><span widgetparams="bookmark?text=[1]&amp;inlineWidget=true&amp;bookmarkID=wikiReference1" class="inlineWidgetContainer" id="widget-5undefined"></span> K%2EA%2E Hoadley%2C C%2E Yau%2C D%2EM%2E Wolf%2C A%2ED%2E Cherniack%2C D%2E Tamborero%2C S%2E Ng%2C M%2ED%2EM%2E Leiserson%2C B%2E Niu%2C M%2ED%2E McLellan%2C V%2E Uzunangelov%2C J%2E Zhang%2C C%2E Kandoth%2C R%2E Akbani%2C H%2E Shen%2C L%2E Omberg%2C A%2E Chu%2C A%2EA%2E Margolin%2C L%2EJ%2E van’t Veer%2C N%2E Lopez%2DBigas%2C P%2EW%2E Laird%2C B%2EJ%2E Raphael%2C L%2E Ding%2C A%2EG%2E Robertson%2C L%2EA%2E Byers%2C G%2EB%2E Mills%2C J%2EN%2E Weinstein%2C C%2E Van Waes%2C Z%2E Chen%2C E%2EA%2E Collisson%2C The Cancer Genome Atlas Research Network%2C C%2EC%2E Benz%2C C%2EM%2E Perou%2C and J%2EM%2E Stuart %282014%29%2E Multiplatform Analysis of 12 Cancer Types Reveals Molecular Classification within and across Tissues of Origin%2E Cell 158%2E http%3A%2F%2Fdx%2Edoi%2Eorg%2F10%2E1016%2Fj%2Ecell%2E2014%2E06%2E049</p>
<p><span id="wikiFootnote2"></span><span widgetparams="bookmark?text=[1]&amp;inlineWidget=true&amp;bookmarkID=wikiReference1" class="inlineWidgetContainer" id="widget-5undefined"></span> K%2EA%2E Hoadley%2C C%2E Yau%2C D%2EM%2E Wolf%2C A%2ED%2E Cherniack%2C D%2E Tamborero%2C S%2E Ng%2C M%2ED%2EM%2E Leiserson%2C B%2E Niu%2C M%2ED%2E McLellan%2C V%2E Uzunangelov%2C J%2E Zhang%2C C%2E Kandoth%2C R%2E Akbani%2C H%2E Shen%2C L%2E Omberg%2C A%2E Chu%2C A%2EA%2E Margolin%2C L%2EJ%2E van’t Veer%2C N%2E Lopez%2DBigas%2C P%2EW%2E Laird%2C B%2EJ%2E Raphael%2C L%2E Ding%2C A%2EG%2E Robertson%2C L%2EA%2E Byers%2C G%2EB%2E Mills%2C J%2EN%2E Weinstein%2C C%2E Van Waes%2C Z%2E Chen%2C E%2EA%2E Collisson%2C The Cancer Genome Atlas Research Network%2C C%2EC%2E Benz%2C C%2EM%2E Perou%2C and J%2EM%2E Stuart %282014%29%2E Multiplatform Analysis of 12 Cancer Types Reveals Molecular Classification within and across Tissues of Origin%2E Cell 158%2E http%3A%2F%2Fdx%2Edoi%2Eorg%2F10%2E1016%2Fj%2Ecell%2E2014%2E06%2E049</p>
.

coverage
Expand Down

0 comments on commit 7635124

Please sign in to comment.