Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Add math and mathblock commands
Browse files Browse the repository at this point in the history
Fixes #254
  • Loading branch information
zhuochun committed Oct 15, 2018
1 parent dbb8576 commit 19eed57
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 29 deletions.
8 changes: 8 additions & 0 deletions lib/config.cson
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ textRangeSelectBy: "nearestWord"
textStyles:
code:
before: "`", after: "`", scopeSelector: ".raw"
math:
before: "$$", after: "$$", scopeSelector: ".math"
bold:
before: "**", after: "**", scopeSelector: ".bold"
italic:
Expand All @@ -126,6 +128,12 @@ textStyles:
regexBefore: "```(?:[\\w- ]+)?\\r?\\n"
regexAfter: "\\r?\\n```"
selectBy: "currentParagraph"
mathblock:
before: "$$\n"
after: "\n$$"
regexBefore: "\\$\\$\\r?\\n"
regexAfter: "\\r?\\n\\$\\$"
selectBy: "currentParagraph"
deletion:
before: "{--", after: "--}", scopeSelector: "critic."
addition:
Expand Down
6 changes: 4 additions & 2 deletions lib/markdown-writer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ module.exports =
editorCommands["markdown-writer:insert-#{media}"] =
@registerView("./views/insert-#{media}-view")

["code", "codeblock", "bold", "italic", "strikethrough", "keystroke",
["code", "codeblock", "math", "mathblock",
"bold", "italic", "strikethrough", "keystroke",
"deletion", "addition", "substitution", "comment", "highlight"
].forEach (style) =>
editorCommands["markdown-writer:toggle-#{style}-text"] =
@registerCommand("./commands/style-text", args: style)

["h1", "h2", "h3", "h4", "h5", "ul", "ol", "task", "taskdone", "blockquote"].forEach (style) =>
["h1", "h2", "h3", "h4", "h5", "ul", "ol",
"task", "taskdone", "blockquote"].forEach (style) =>
editorCommands["markdown-writer:toggle-#{style}"] =
@registerCommand("./commands/style-line", args: style)

Expand Down
68 changes: 41 additions & 27 deletions menus/menu.cson
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,11 @@
'label': 'Insert Image',
'command': 'markdown-writer:insert-image'
}
{
'label': 'Insert Table',
'command': 'markdown-writer:insert-table'
}
{
'label': 'Insert Footnote',
'command': 'markdown-writer:insert-footnote'
}
{ 'type': 'separator' }
{
'label': 'Code',
'command': 'markdown-writer:toggle-code-text'
}
{
'label': 'Code Block',
'command': 'markdown-writer:toggle-codeblock-text'
}
{
'label': 'Bold',
'command': 'markdown-writer:toggle-bold-text'
Expand All @@ -81,24 +69,20 @@
}
{ 'type': 'separator' }
{
'label': 'deletion',
'command': 'markdown-writer:toggle-deletion-text'
}
{
'label': 'addition',
'command': 'markdown-writer:toggle-addition-text'
'label': 'Code',
'command': 'markdown-writer:toggle-code-text'
}
{
'label': 'substitution',
'command': 'markdown-writer:toggle-substitution-text'
'label': 'Code Block',
'command': 'markdown-writer:toggle-codeblock-text'
}
{
'label': 'comment',
'command': 'markdown-writer:toggle-comment-text'
'label': 'Math',
'command': 'markdown-writer:toggle-math-text'
}
{
'label': 'highlight',
'command': 'markdown-writer:toggle-highlight-text'
'label': 'Math Block',
'command': 'markdown-writer:toggle-mathblock-text'
}
{ 'type': 'separator' }
{
Expand Down Expand Up @@ -135,7 +119,7 @@
'command': 'markdown-writer:toggle-task'
}
{
'label': 'Task List (Done)'
'label': 'Toggle Task List'
'command': 'markdown-writer:toggle-taskdone'
}
{ 'type': 'separator' }
Expand All @@ -145,9 +129,38 @@
}
]
}
{
'label': 'CriticMarkup'
'submenu': [
{
'label': 'Addition',
'command': 'markdown-writer:toggle-addition-text'
}
{
'label': 'Deletion',
'command': 'markdown-writer:toggle-deletion-text'
}
{
'label': 'Substitution',
'command': 'markdown-writer:toggle-substitution-text'
}
{
'label': 'Comment',
'command': 'markdown-writer:toggle-comment-text'
}
{
'label': 'Highlight',
'command': 'markdown-writer:toggle-highlight-text'
}
]
}
{
'label': 'Table'
'submenu': [
{
'label': 'Insert Table',
'command': 'markdown-writer:insert-table'
}
{
'label': 'Format Table'
'command': 'markdown-writer:format-table'
Expand All @@ -166,6 +179,7 @@
'label': 'Fold All Links'
'command': 'markdown-writer:fold-links'
}
{ 'type': 'separator' }
{
'label': 'Unfold All'
'command': 'editor:unfold-all'
Expand All @@ -190,8 +204,8 @@
}
{ 'type': 'separator' }
{
'label': 'Fold All Links'
'command': 'markdown-writer:fold-links'
'label': 'Format Ordered List'
'command': 'markdown-writer:format-order-list'
}
{ 'type': 'separator' }
{
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"markdown-writer:insert-table",
"markdown-writer:toggle-code-text",
"markdown-writer:toggle-codeblock-text",
"markdown-writer:toggle-math-text",
"markdown-writer:toggle-mathblock-text",
"markdown-writer:toggle-bold-text",
"markdown-writer:toggle-italic-text",
"markdown-writer:toggle-keystroke-text",
Expand Down

0 comments on commit 19eed57

Please sign in to comment.