ep_markdown 11.0.14 → 11.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/exportMarkdown.ts +28 -3
- package/package.json +1 -1
package/exportMarkdown.ts
CHANGED
|
@@ -218,9 +218,27 @@ const getMarkdownFromAtext = (pad, atext) => {
|
|
|
218
218
|
const url = urlData[1];
|
|
219
219
|
const urlLength = url.length;
|
|
220
220
|
processNextChars(startIndex - idx);
|
|
221
|
+
// Close any currently-open inline format tags (bold, italic, etc.)
|
|
222
|
+
// before writing the URL. If we don't, processing the URL's chars
|
|
223
|
+
// re-emits `**` / `*` markers *inside* the Markdown link token,
|
|
224
|
+
// producing broken output like `[url](**https://example.com**)`
|
|
225
|
+
// (regression for #156).
|
|
226
|
+
const reopen = [...openTags];
|
|
227
|
+
const tags2close = [...openTags];
|
|
228
|
+
orderdCloseTags(tags2close);
|
|
229
|
+
for (let i = 0; i < propVals.length; i++) { propVals[i] = false; }
|
|
221
230
|
assem.append(`[${url}](`);
|
|
222
|
-
|
|
231
|
+
// Emit the URL's chars as raw text — links in Markdown never
|
|
232
|
+
// contain inline formatting markers.
|
|
233
|
+
assem.append(taker.take(urlLength));
|
|
234
|
+
idx += urlLength;
|
|
223
235
|
assem.append(')');
|
|
236
|
+
// Restore the formatting tags so any trailing same-line text picks
|
|
237
|
+
// them back up.
|
|
238
|
+
for (const i of reopen.slice().reverse()) {
|
|
239
|
+
emitOpenTag(i);
|
|
240
|
+
propVals[i] = true;
|
|
241
|
+
}
|
|
224
242
|
});
|
|
225
243
|
}
|
|
226
244
|
|
|
@@ -229,8 +247,15 @@ const getMarkdownFromAtext = (pad, atext) => {
|
|
|
229
247
|
// replace &, _
|
|
230
248
|
assem = assem.toString();
|
|
231
249
|
assem = assem.replace(/&/g, '\\&');
|
|
232
|
-
//
|
|
233
|
-
|
|
250
|
+
// Only escape underscores OUTSIDE code spans / code blocks. On a line
|
|
251
|
+
// with the `heading: 'code'` attribute (rendered with the 4-space
|
|
252
|
+
// block-code prefix) underscores should be preserved verbatim,
|
|
253
|
+
// otherwise `myVar_name` comes out as `myVar\_name` in the exported
|
|
254
|
+
// Markdown rendering (regression for #156). Math-mode ($...$) still
|
|
255
|
+
// has no special handling here — that is a separate concern.
|
|
256
|
+
if (heading !== headingtags[6]) {
|
|
257
|
+
assem = assem.replace(/_/g, '\\_');
|
|
258
|
+
}
|
|
234
259
|
|
|
235
260
|
return assem;
|
|
236
261
|
};
|