Skip to content

Commit

Permalink
Merge pull request #6 from ariabuckles/one-line-headings
Browse files Browse the repository at this point in the history
Headings: Allow # headings to be ended with a single newline
  • Loading branch information
Benjamin-Dobell authored Sep 8, 2017
2 parents cb8b9a7 + 6524ad2 commit 1b2cb24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion MarkdownView.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function mergeRules(baseRules, rules) {
return mergedRules
}

const IMAGE_LINK = "(?:\\[[^\\]]*\\]|[^\\]]|\\](?=[^\\[]*\\]))*"
const IMAGE_LINK = "(?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*";
const IMAGE_HREF_AND_TITLE = "\\s*<?((?:[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?"
const IMAGE_SIZE = "(?:\\s+=([0-9]+)x([0-9]+))?\\)\\s*"

Expand All @@ -58,6 +58,9 @@ const DefaultRules : Rules = Object.freeze(mergeRules(
...Object.entries(DefaultRenders).map(([nodeKey, render]) => ({[nodeKey]: {render: render}}))
),
{
heading: {
match: SimpleMarkdown.blockRegex(/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n *)*\n/),
},
image: {
match: inlineRegex(new RegExp("^!\\[(" + IMAGE_LINK + ")\\]\\(" + IMAGE_HREF_AND_TITLE + IMAGE_SIZE)),
parse: (capture, parse, state): ImageNode => ({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"dependencies": {
"prop-types": "^15.5.10",
"react-native-tabular-grid": "github:Benjamin-Dobell/react-native-tabular-grid",
"simple-markdown": "^0.2.1"
"simple-markdown": "0.3.x"
},
"devDependencies": {
"flow-bin": "^0.36.0"
Expand Down

0 comments on commit 1b2cb24

Please sign in to comment.