From 5d5c289337e9302cb47f614cd5f84c3b92b691b3 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Thu, 12 Sep 2024 23:55:07 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=A7=20Strike-through=20macros=20in=20l?= =?UTF-8?q?atex=20(#1532)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/nine-llamas-march.md | 5 +++++ packages/tex-to-myst/src/marks.ts | 3 +++ packages/tex-to-myst/src/tex.ts | 4 ++++ packages/tex-to-myst/src/utils.ts | 1 + packages/tex-to-myst/tests/text.yml | 11 +++++++++++ 5 files changed, 24 insertions(+) create mode 100644 .changeset/nine-llamas-march.md diff --git a/.changeset/nine-llamas-march.md b/.changeset/nine-llamas-march.md new file mode 100644 index 000000000..6a6ffcf41 --- /dev/null +++ b/.changeset/nine-llamas-march.md @@ -0,0 +1,5 @@ +--- +"tex-to-myst": patch +--- + +Add cancel to latex diff --git a/packages/tex-to-myst/src/marks.ts b/packages/tex-to-myst/src/marks.ts index 6fbc5601d..eff700046 100644 --- a/packages/tex-to-myst/src/marks.ts +++ b/packages/tex-to-myst/src/marks.ts @@ -11,6 +11,9 @@ const marks = { textsubscript: 'subscript', textsuperscript: 'superscript', hl: 'strong', // This needs to be done! + cancel: 'delete', + bcancel: 'delete', + xcancel: 'delete', }; const TEXT_MARKS_HANDLERS: Record = { diff --git a/packages/tex-to-myst/src/tex.ts b/packages/tex-to-myst/src/tex.ts index 75e3204c5..aa490932b 100644 --- a/packages/tex-to-myst/src/tex.ts +++ b/packages/tex-to-myst/src/tex.ts @@ -133,6 +133,10 @@ const macros: Record = { t: 1, u: 1, v: 1, + // Cancel + cancel: 1, + bcancel: 1, + xcancel: 1, }; // These macros allow a mix of {} and [] arguments, rather than only allowing diff --git a/packages/tex-to-myst/src/utils.ts b/packages/tex-to-myst/src/utils.ts index 65df2dc46..1bef8218e 100644 --- a/packages/tex-to-myst/src/utils.ts +++ b/packages/tex-to-myst/src/utils.ts @@ -100,6 +100,7 @@ export const phrasingTypes = new Set([ 'smallcaps', 'link', 'span', + 'delete', ]); export const UNHANDLED_ERROR_TEXT = 'Unhandled TEX conversion'; diff --git a/packages/tex-to-myst/tests/text.yml b/packages/tex-to-myst/tests/text.yml index 0ba2c3418..02974e486 100644 --- a/packages/tex-to-myst/tests/text.yml +++ b/packages/tex-to-myst/tests/text.yml @@ -151,3 +151,14 @@ cases: children: - type: text value: ok ok + - title: Strike-through and delete + tex: \cancel{me} + tree: + type: root + children: + - type: paragraph + children: + - type: delete + children: + - type: text + value: me