Skip to content

Commit bd74033

Browse files
committed
feat(remark-editorial-elements): add :sic and :ellipsis
1 parent 96aede1 commit bd74033

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

packages/remark-editorial-elements/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ TODO
4343

4444
## Syntax
4545

46+
### `:sic` (inline)
47+
48+
```markdown
49+
> It’s true taht :sic{} they said
50+
```
51+
52+
### `:ellipsis` (inline)
53+
54+
```markdown
55+
> We were told it’s very :ellipsis{} good for the soul
56+
```
57+
4658
### `:ins` (inline, insertions)
4759

4860
```markdown

packages/remark-editorial-elements/src/index.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,37 @@ export function editingPlugin(options: Partial<Options>) {
4545
visit(tree, { type: "textDirective", name: "ins" }, (node: Directive) => {
4646
changeName(node, "ins", ["inline"]);
4747
});
48+
visit(tree, { type: "textDirective", name: "sic" }, sicVisitor);
49+
visit(tree, { type: "textDirective", name: "ellipsis" }, ellipsisVisitor);
50+
}
51+
52+
function ellipsisVisitor(node: Parent) {
53+
node.data = {
54+
...node.data,
55+
hName: "ins",
56+
hProperties: { class: "editorial" },
57+
hChildren: [{ type: "text", value: "[…]" }],
58+
};
59+
}
60+
61+
function sicVisitor(node: Parent) {
62+
node.data = {
63+
...node.data,
64+
hName: "ins",
65+
hProperties: { class: "editorial" },
66+
hChildren: [
67+
{
68+
type: "element",
69+
tagName: "abbr",
70+
hName: "abbr",
71+
properties: {
72+
class: "sic",
73+
title: "Spelling Is Correct",
74+
},
75+
children: [{ type: "text", value: "[sic]" }],
76+
},
77+
],
78+
};
4879
}
4980
}
5081

0 commit comments

Comments
 (0)