Skip to content

Commit

Permalink
Fix for Issue winterstein#67
Browse files Browse the repository at this point in the history
  • Loading branch information
JensPiegsa committed Aug 3, 2016
1 parent c533e1c commit 09e7630
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions plugin/src/winterwell/markdown/pagemodel/MarkdownPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,34 +325,46 @@ private void setText(String text) {
lineNum = 0;
}
}

boolean githubSyntaxSupport =
pStore.getBoolean(MarkdownPreferencePage.PREF_GITHUB_SYNTAX);

boolean inCodeBlock = false;

for (; lineNum < lines.size(); lineNum++) {
String line = lines.get(lineNum);
// Headings
int h = numHash(line);
String hLine = line;
int hLineNum = lineNum;
int underline = -1;
if (lineNum != 0) {
underline = just(line, '=') ? 1 : just(line, '-') ? 2 : -1;
}
if (underline != -1) {
h = underline;
hLineNum = lineNum - 1;
hLine = lines.get(lineNum - 1);
lineTypes.set(hLineNum, KLineType.values()[h]);
lineTypes.add(KLineType.MARKER);
// Code blocks
if (githubSyntaxSupport && line.startsWith("```")) {
inCodeBlock = !inCodeBlock;
}
// Create a Header object
if (h > 0) {
if (underline == -1)
lineTypes.add(KLineType.values()[h]);
Header header = new Header(h, hLineNum, hLine, currentHeader);
if (h == 1) {
level1Headers.add(header);
if (!inCodeBlock) {
// Headings
int h = numHash(line);
String hLine = line;
int hLineNum = lineNum;
int underline = -1;
if (lineNum != 0) {
underline = just(line, '=') ? 1 : just(line, '-') ? 2 : -1;
}
if (underline != -1) {
h = underline;
hLineNum = lineNum - 1;
hLine = lines.get(lineNum - 1);
lineTypes.set(hLineNum, KLineType.values()[h]);
lineTypes.add(KLineType.MARKER);
}
// Create a Header object
if (h > 0) {
if (underline == -1)
lineTypes.add(KLineType.values()[h]);
Header header = new Header(h, hLineNum, hLine, currentHeader);
if (h == 1) {
level1Headers.add(header);
}
pageObjects.put(hLineNum, header);
currentHeader = header;
continue;
}
pageObjects.put(hLineNum, header);
currentHeader = header;
continue;
}
// TODO List
// TODO Block quote
Expand All @@ -368,14 +380,11 @@ private void setText(String text) {
if (dummyTopHeader.getSubHeaders().size() == 0) {
level1Headers.remove(dummyTopHeader);
}

boolean githubSyntaxSupport =
pStore.getBoolean(MarkdownPreferencePage.PREF_GITHUB_SYNTAX);
if (githubSyntaxSupport) {
/*
* Support Code block
*/
boolean inCodeBlock = false;
inCodeBlock = false;
for (lineNum = 0; lineNum < lines.size(); lineNum++) {
String line = lines.get(lineNum);
// Found the start or end of a code block
Expand Down

0 comments on commit 09e7630

Please sign in to comment.