Skip to content

Commit

Permalink
0.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
shd101wyy committed Sep 30, 2015
1 parent 7460ec0 commit 8cad8b4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.3.7
* fix image path bug when export pdf and html

## 0.3.6
* fix math expression parsing bug... caused by \_underscore\_

Expand Down
19 changes: 10 additions & 9 deletions lib/atom-markdown-katex.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var fs = require("fs")
var cheerio = require("cheerio")
var temp = require('temp')
var exec = require('child_process').exec
var path = require('path')

/*
* This pdfIFrame is added to document.body once.
Expand Down Expand Up @@ -120,7 +121,7 @@ function resolveImagePaths(html, directoryPath) {
(src.startsWith('./') ||
src.startsWith('../') ||
src[0] !== '/')) {
img.attr('src', directoryPath + '//' + src)
img.attr('src', path.resolve(directoryPath, src))
}
})
return $.html()
Expand Down Expand Up @@ -154,7 +155,7 @@ function beginMarkdownKatexPreview() {
// get current selected active editor
var activeEditor = atom.workspace.getActiveTextEditor()
var filePath = activeEditor.buffer.file.path
var rootDirectoryPath = atom.project.relativizePath(filePath)
var rootDirectoryPath = path.resolve(path.dirname(filePath))

// already activated
if (activeEditor.markdownHtmlView) {
Expand All @@ -169,7 +170,7 @@ function beginMarkdownKatexPreview() {
if (activeEditor.markdownHtmlView) {
activeEditor.markdownHtmlView.style.display = "inline"
activeEditor.htmlPreviewEditor.textContent = activeEditor.getText()
activeEditor.markdownHtmlView.innerHTML = parseMD(activeEditor.getText(), rootDirectoryPath[0])
activeEditor.markdownHtmlView.innerHTML = parseMD(activeEditor.getText(), rootDirectoryPath )
}
}
});
Expand Down Expand Up @@ -234,7 +235,7 @@ function beginMarkdownKatexPreview() {
activeEditor.onDidChange(function() {
if (activeEditor.markdownHtmlView) {
activeEditor.htmlPreviewEditor.textContent = activeEditor.getText()
activeEditor.markdownHtmlView.innerHTML = parseMD(activeEditor.getText(), rootDirectoryPath[0])
activeEditor.markdownHtmlView.innerHTML = parseMD(activeEditor.getText(), rootDirectoryPath )
}
})

Expand All @@ -244,16 +245,16 @@ function beginMarkdownKatexPreview() {
}

// set content
activeEditor.markdownHtmlView.innerHTML = parseMD(activeEditor.getText(), rootDirectoryPath[0])
});
activeEditor.markdownHtmlView.innerHTML = parseMD(activeEditor.getText(), rootDirectoryPath )
})
}

// get offline html content
function getOfflineHTMLContent() {
var editor = atom.workspace.getActiveTextEditor()
var rootDirectoryPath = editor.rootDirectoryPath
var textContent = editor.textContent
var htmlContent = parseMD(textContent)
var htmlContent = parseMD(textContent, rootDirectoryPath)

var indexCSS = fs.readFileSync(__dirname + "/index.css", 'utf8')
var highlightCSS = fs.readFileSync(__dirname + "/highlight.js/default.css", 'utf8')
Expand All @@ -278,7 +279,7 @@ function saveAsPDF() {
} else {
fs.write(info.fd, htmlContent, function() {
// set the src last.
pdfIFrame.src = info.path;
pdfIFrame.src = info.path
})
}
})
Expand All @@ -289,7 +290,7 @@ function copyAsHTML() {
var editor = atom.workspace.getActiveTextEditor()
var rootDirectoryPath = editor.rootDirectoryPath
var textContent = editor.textContent
var htmlContent = parseMD(textContent)
var htmlContent = parseMD(textContent, rootDirectoryPath)

var indexCSS = fs.readFileSync(__dirname + "/index.css", 'utf8')
var highlightCSS = fs.readFileSync(__dirname + "/highlight.js/default.css", 'utf8')
Expand Down
6 changes: 3 additions & 3 deletions lib/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
-webkit-print-color-adjust: exact;
}
.markdown-katex-preview .newpage {
page-break-before: always;
page-break-before: always;
}

@media screen and (min-width: 914px) {
Expand Down Expand Up @@ -166,7 +166,7 @@
}
.markdown-katex-preview img{
display: block;
width: 100%;
height: 100%;
max-width: 100%;
max-height: 100%;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "atom-markdown-katex",
"main": "./lib/atom-markdown-katex",
"version": "0.3.6",
"version": "0.3.7",
"description": "Markdown preview with KaTex support. Easy export to pdf/html",
"activationCommands": {
"atom-workspace": [
Expand Down
Binary file added test/1.pic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var add = function(x, y){

> export your markdown to PDF or HTML
<img src="./1.pic.jpg" height=400>
---
** Bugs Fix **
- [\$ bug](https://github.com/shd101wyy/atom-markdown-katex/issues/2)
Expand Down

0 comments on commit 8cad8b4

Please sign in to comment.