Skip to content

Commit

Permalink
Merge pull request #34 from shd101wyy/0.2.2
Browse files Browse the repository at this point in the history
0.2.2
  • Loading branch information
shd101wyy authored Jul 28, 2017
2 parents 57b79d1 + 20813f7 commit a8e64f0
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 18 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
*Still Beta Version!*

## Supporting this project
Markdown Preview Enhanced is an open source project released under the [University of Illinois/NCSA Open Source License](LICENSE.md). Its ongoing development is made possible thanks to the support by these awesome [backers](https://shd101wyy.github.io/markdown-preview-enhanced/#/backers). You can help make this project better by [supporting us on Patreon](https://www.patreon.com/shd101wyy) or [微信支付 Wechat Pay](https://shd101wyy.github.io/markdown-preview-enhanced/#/wechat). Thank you!
Markdown Preview Enhanced is an open source project released under the [University of Illinois/NCSA Open Source License](LICENSE.md). Its ongoing development is made possible thanks to the support by these awesome [backers](https://shd101wyy.github.io/markdown-preview-enhanced/#/backers). You can help make this project better by [supporting us on Patreon](https://www.patreon.com/shd101wyy), [PayPal](https://shd101wyy.github.io/markdown-preview-enhanced/#/paypal), or [微信支付 Wechat Pay](https://shd101wyy.github.io/markdown-preview-enhanced/#/wechat). Thank you!

## Introduction
Markdown Preview Enhanced is an extension that provides you with many useful functionalities such as automatic scroll sync, math typesetting, mermaid, PlantUML, pandoc, PDF export, code chunk, etc. A lot of its ideas are inspired by [Markdown Preview Plus](https://github.com/atom-community/markdown-preview-plus) and [RStudio Markdown](http://rmarkdown.rstudio.com/).
Markdown Preview Enhanced is an extension that provides you with many useful functionalities such as automatic scroll sync, [math typesetting](https://shd101wyy.github.io/markdown-preview-enhanced/#/math), [mermaid](https://shd101wyy.github.io/markdown-preview-enhanced/#/diagrams?id=mermaid), [PlantUML](https://shd101wyy.github.io/markdown-preview-enhanced/#/diagrams?id=plantuml), [pandoc](https://shd101wyy.github.io/markdown-preview-enhanced/#/pandoc), PDF export, [code chunk](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk), [presentation writer](https://rawgit.com/shd101wyy/markdown-preview-enhanced/master/docs/presentation-intro.html), etc. A lot of its ideas are inspired by [Markdown Preview Plus](https://github.com/atom-community/markdown-preview-plus) and [RStudio Markdown](http://rmarkdown.rstudio.com/).

Feel free to ask questions, post issues, submit pull request, and request new features.

Expand All @@ -34,6 +34,21 @@ To check out the documentation, visit

Contact me if you are willing to help translate the documentation :)

## Keybindings
> The <kbd>cmd</kbd> key for *Windows* is <kbd>ctrl</kbd>.
| Shortcuts | Functionality |
|---|---|
| <kbd>cmd-k v</kbd> or <kbd>ctrl-shift-m</kbd> | Open preview |
| <kbd>ctrl-shift-s</kbd> | Sync preview / Sync source |
| <kbd>ctrl-shift-i</kbd> | Open Image Helper |
| <kbd>shift-enter</kbd> | Run Code Chunk |
| <kbd>ctrl-shift-enter</kbd> | Run all Code Chunks |
| <kbd>cmd-=</kbd> or <kbd>cmd-shift-=</kbd> | Preview zoom in |
| <kbd>cmd--</kbd> or <kbd>cmd-shift-\_</kbd> | Preview zoom out |
| <kbd>cmd-0</kbd> | Preview reset zoom |
| <kbd>esc</kbd> | Toggle sidebar TOC |

## Changelog
Please check the [Releases](https://github.com/shd101wyy/vscode-markdown-preview-enhanced/releases) page of this project.

Expand Down
68 changes: 68 additions & 0 deletions docs/newest.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
## Anouncement
I will be busy hunting jobs (August & September), so I won't have time to implement new features for this extension.
The updates in the following two months will be bug fixes only.

## 0.2.2
* Deprecated the old way of defining attribtues (still supported but not recommened) [#529](https://github.com/shd101wyy/markdown-preview-enhanced/issues/529). Now attributes should be defined like below in order to be compatible with the pandoc parser:

{#identifier .class .class key=value key=value}


And here are a few changes:

# Hi {#id .class1 .class2}

Show `line-numbers`
```javascript {.line-numbers}
x = 1
```

```python {cmd=true output="markdown"}
print("**Hi there**")
```

<!-- slide vertical=true .slide-class1 .slide-class2 #slide-id -->

\@import "test.png" {width=50% height=30%}
* Added a few more preview themes.
* Supported [vega](https://vega.github.io/vega/) and [vega-lite](https://vega.github.io/vega-lite/). [#524](https://github.com/shd101wyy/markdown-preview-enhanced/issues/524).

* Code block with `vega` notation will be rendered by [vega](https://vega.github.io/vega/).
* Code block with `vega-lite` notation will be rendered by [vega-lite](https://vega.github.io/vega-lite/).
* Both `JSON` and `YAML` inputs are supported.

![screen shot 2017-07-28 at 7 59 58 am](https://user-images.githubusercontent.com/1908863/28718265-d023e1c2-736a-11e7-8678-a29704f3a23c.png)

You can also [@import](https://shd101wyy.github.io/markdown-preview-enhanced/#/file-imports) a `JSON` or `YAML` file as `vega` diagram, for example:

<pre>
\@import "your_vega_source.json" {as:"vega"}
\@import "your_vega_lite_source.json" {as:"vega-lite"}
</pre>

* Supported [ditaa](https://github.com/stathissideris/ditaa).
ditaa can convert diagrams drawn using ascii art ('drawings' that contain characters that resemble lines like | / - ), into proper bitmap graphics. (**Java** is required to be installed)

`ditaa` is intergrated with [code chunk](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk), for example:
<pre>
```ditaa {cmd=true args=["-E"]}
+--------+ +-------+ +-------+
| | --+ ditaa +--> | |
| Text | +-------+ |diagram|
|Document| |!magic!| | |
| {d}| | | | |
+---+----+ +-------+ +-------+
: ^
| Lots of work |
+-------------------------+
```
</pre>

> <kbd>shift-enter</kbd> to run code chunk.
> set `{hide=true}` to hide code block.
> set `{run_on_save=true}` to render ditaa when you save the markdown file.
![screen shot 2017-07-28 at 8 11 15 am](https://user-images.githubusercontent.com/1908863/28718626-633fa18e-736c-11e7-8a4a-915858dafff6.png)



## 0.2.0, 0.2.1
* Upgraded [mume](https://github.com/shd101wyy/mume) to version `0.1.5`.
* Fixed header id bug [#516](https://github.com/shd101wyy/markdown-preview-enhanced/issues/516).
Expand Down
2 changes: 1 addition & 1 deletion docs/welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!-- anchor -->

@import "https://i.ytimg.com/vi/YgjzquvzTXU/maxresdefault.jpg" {width: 500, style: "position:relative; left: 50%; transform: translateX(-50%);"}
@import "https://user-images.githubusercontent.com/1908863/28734960-d71fb3dc-73a8-11e7-8555-847373d1ed0f.gif" {width: 500, style: "position:relative; left: 50%; transform: translateX(-50%);"}
<br>
<br>
<p align="center">
Expand Down
43 changes: 34 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
"key": "shift+ctrl+m",
"when": "editorLangId == markdown"
},
{
"command": "markdown-preview-enhanced.openPreview",
"key": "ctrl+k v",
"mac": "cmd+k v",
"when": "editorLangId == markdown"
},
{
"command": "markdown-preview-enhanced.openImageHelper",
"key": "shift+ctrl+i",
Expand Down Expand Up @@ -211,22 +217,28 @@
]
},
"markdown-preview-enhanced.codeBlockTheme": {
"description": "Code block theme.",
"default": "default.css",
"description": "Code block theme. If `auto.css` is chosen, then the code block theme that best matches the current preview theme will be picked.",
"default": "auto.css",
"type": "string",
"enum": [
"auto.css",
"default.css",
"atom-dark.css",
"atom-light.css",
"atom-material.css",
"coy.css",
"darcula.css",
"dark.css",
"default.css",
"funky.css",
"github.css",
"hopscotch.css",
"monokai.css",
"okaidia.css",
"onedark.css",
"one-dark.css",
"one-light.css",
"pen-paper-coffee.css",
"pojoaque.css",
"solarized-dark.css",
"solarized-light.css",
"twilight.css",
"vs.css",
Expand All @@ -238,13 +250,21 @@
"default": "github-light.css",
"type": "string",
"enum": [
"github-light.css",
"atom-dark.css",
"atom-light.css",
"atom-material.css",
"github-dark.css",
"github-light.css",
"gothic.css",
"medium.css",
"monokai.css",
"newsprint.css",
"night.css",
"medium.css",
"none.css"
"none.css",
"one-dark.css",
"one-light.css",
"solarized-dark.css",
"solarized-light.css"
]
},
"markdown-preview-enhanced.revealjsTheme": {
Expand Down Expand Up @@ -314,6 +334,11 @@
"description": "Default latex engine for Pandoc export and latex code chunk.",
"default": "pdflatex",
"type": "string"
},
"markdown-preview-enhanced.enableScriptExecution": {
"description": "Disabling this will prevent executing code chunks and importing javascript files.",
"default": true,
"type": "boolean"
}
}
}
Expand All @@ -326,7 +351,7 @@
"package": "vsce package"
},
"dependencies": {
"@shd101wyy/mume": "^0.1.5"
"@shd101wyy/mume": "^0.1.6"
},
"devDependencies": {
"@types/jquery": "^2.0.46",
Expand All @@ -337,4 +362,4 @@
"typescript": "^2.0.3",
"vscode": "^1.0.0"
}
}
}
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class MarkdownPreviewEnhancedConfig implements MarkdownEngineConfig {
public readonly pandocMarkdownFlavor: string
public readonly pandocArguments: string[]
public readonly latexEngine: string
public readonly enableScriptExecution: boolean

// preview config
public readonly scrollSync: boolean
Expand Down Expand Up @@ -59,6 +60,7 @@ export class MarkdownPreviewEnhancedConfig implements MarkdownEngineConfig {
this.pandocMarkdownFlavor = config.get<string>('pandocMarkdownFlavor')
this.pandocArguments = config.get<string>('pandocArguments').split(',').map((x)=> x.trim())
this.latexEngine = config.get<string>('latexEngine')
this.enableScriptExecution = config.get<boolean>('enableScriptExecution')

this.scrollSync = config.get<boolean>('scrollSync')
}
Expand Down
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function activate(context: vscode.ExtensionContext) {
const editor = vscode.window.activeTextEditor
if (editor && editor.document && editor.edit) {
editor.edit((textEdit)=> {
textEdit.insert(editor.selection.active, '\n<!-- @import "[TOC]" {cmd:"toc", depthFrom:1, depthTo:6, orderedList:false} -->\n')
textEdit.insert(editor.selection.active, '\n<!-- @import "[TOC]" {cmd="toc" depthFrom=1 depthTo=6 orderedList=false} -->\n')
})
}
}
Expand Down Expand Up @@ -432,6 +432,8 @@ export function activate(context: vscode.ExtensionContext) {

context.subscriptions.push(vscode.commands.registerCommand('_mume.clickTaskListCheckbox', clickTaskListCheckbox))

context.subscriptions.push(vscode.commands.registerCommand('_mume.showUploadedImageHistory', showUploadedImages))

context.subscriptions.push(contentProviderRegistration)
}

Expand Down
17 changes: 12 additions & 5 deletions src/preview-content-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ export class MarkdownPreviewEnhancedView implements vscode.TextDocumentContentPr
private async modifySource(codeChunkData:mume.CodeChunkData, result:string, filePath:string):Promise<string> {
function insertResult(i:number, editor:TextEditor) {
const lineCount = editor.document.lineCount
if (i + 1 < lineCount && editor.document.lineAt(i + 1).text.startsWith('<!-- code_chunk_output -->')) {
let start = 0
// find <!-- code_chunk_output -->
for (let j = i + 1; j < i + 6 && j < lineCount; j++) {
if (editor.document.lineAt(j).text.startsWith('<!-- code_chunk_output -->')) {
start = j
break
}
}
if (start) { // found
// TODO: modify exited output
let start = i + 1
let end = i + 2
let end = start + 1
while (end < lineCount) {
if (editor.document.lineAt(end).text.startsWith('<!-- /code_chunk_output -->')){
break
Expand Down Expand Up @@ -116,7 +123,7 @@ export class MarkdownPreviewEnhancedView implements vscode.TextDocumentContentPr
const lineCount = editor.document.lineCount
for (let i = 0; i < lineCount; i++) {
const line = editor.document.lineAt(i)
if (line.text.match(/^```(.+)\"?cmd\"?\s*\:/)) {
if (line.text.match(/^```(.+)\"?cmd\"?\s*[:=]/)) {
if (codeChunkOffset === targetCodeChunkOffset) {
i = i + 1
while (i < lineCount) {
Expand All @@ -129,7 +136,7 @@ export class MarkdownPreviewEnhancedView implements vscode.TextDocumentContentPr
} else {
codeChunkOffset++
}
} else if (line.text.match(/\@import\s+(.+)\"?cmd\"?\s*\:/)) {
} else if (line.text.match(/\@import\s+(.+)\"?cmd\"?\s*[:=]/)) {
if (codeChunkOffset === targetCodeChunkOffset) {
// console.log('find code chunk' )
return insertResult(i, editor)
Expand Down

0 comments on commit a8e64f0

Please sign in to comment.