4 Commits

Author SHA1 Message Date
dependabot[bot]
74308ff082 Bump github.com/microcosm-cc/bluemonday from 1.0.3 to 1.0.5 in /src/go
Bumps [github.com/microcosm-cc/bluemonday](https://github.com/microcosm-cc/bluemonday) from 1.0.3 to 1.0.5.
- [Release notes](https://github.com/microcosm-cc/bluemonday/releases)
- [Commits](https://github.com/microcosm-cc/bluemonday/compare/v1.0.3...v1.0.5)

---
updated-dependencies:
- dependency-name: github.com/microcosm-cc/bluemonday
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-26 23:35:43 +00:00
1c8cd1c80c Test Mermaid.js diagrams 2021-02-14 13:14:06 -06:00
260e107f84 Fix live code highlighting; add tests 2021-02-14 13:06:37 -06:00
e8f400aa76 Switch to GitHub Markdown from npm 2021-02-14 12:22:38 -06:00
8 changed files with 61 additions and 19 deletions

View File

@@ -22,6 +22,7 @@ all: $(OUTPUT_FILES)
@rsync -a node_modules/mermaid/dist/mermaid.min.js build/static/lib/
@rsync -a node_modules/jquery/dist/jquery.min.js build/static/lib/
@rsync -a node_modules/dropzone/dist/min/dropzone* build/static/lib/
@rsync -a node_modules/github-markdown-css/*css build/static/lib/
$(GO_OUT): $(GO_IN)
cd src/go && go build ${LDFLAGS} -o ../../build/notes
@@ -67,7 +68,7 @@ install-deps:
.PHONY: run
run: all
cd build && ./notes $(DEFAULT_ARGS)
cd build && ./notes $(DEFAULT_ARGS) --data ../data
.PHONY: test
test: all

File diff suppressed because one or more lines are too long

14
package-lock.json generated
View File

@@ -7,6 +7,7 @@
"dependencies": {
"@fontsource/roboto": "^4.2.0",
"dropzone": "^5.7.6",
"github-markdown-css": "^4.0.0",
"jquery": "^3.5.0",
"mathjax": "^3.1.2",
"mermaid": "^8.9.0",
@@ -395,6 +396,14 @@
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/github-markdown-css": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/github-markdown-css/-/github-markdown-css-4.0.0.tgz",
"integrity": "sha512-mH0bcIKv4XAN0mQVokfTdKo2OD5K8WJE9+lbMdM32/q0Ie5tXgVN/2o+zvToRMxSTUuiTRcLg5hzkFfOyBYreg==",
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/graphlib": {
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/graphlib/-/graphlib-2.1.8.tgz",
@@ -985,6 +994,11 @@
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"optional": true
},
"github-markdown-css": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/github-markdown-css/-/github-markdown-css-4.0.0.tgz",
"integrity": "sha512-mH0bcIKv4XAN0mQVokfTdKo2OD5K8WJE9+lbMdM32/q0Ie5tXgVN/2o+zvToRMxSTUuiTRcLg5hzkFfOyBYreg=="
},
"graphlib": {
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/graphlib/-/graphlib-2.1.8.tgz",

View File

@@ -2,6 +2,7 @@
"dependencies": {
"@fontsource/roboto": "^4.2.0",
"dropzone": "^5.7.6",
"github-markdown-css": "^4.0.0",
"jquery": "^3.5.0",
"mathjax": "^3.1.2",
"mermaid": "^8.9.0",

View File

@@ -3,14 +3,14 @@ module github.com/isoron/notes
go 1.12
require (
github.com/gin-contrib/multitemplate v0.0.0-20190528082104-30e424939505
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.4.0
github.com/jcelliott/lumber v0.0.0-20160324203708-dd349441af25
github.com/kr/pretty v0.1.0 // indirect
github.com/litao91/goldmark-mathjax v0.0.0-20200921072530-4c5dae64834a
github.com/mattn/go-isatty v0.0.8 // indirect
github.com/microcosm-cc/bluemonday v1.0.3
github.com/microcosm-cc/bluemonday v1.0.5
github.com/schollz/versionedtext v0.0.0-20180523061923-d8ce0957c254
github.com/ugorji/go v1.1.7 // indirect
github.com/yuin/goldmark v1.3.1

View File

@@ -5,8 +5,6 @@ github.com/chris-ramon/douceur v0.2.0/go.mod h1:wDW5xjJdeoMm1mRt4sD4c/LbF/mWdEpR
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gin-contrib/multitemplate v0.0.0-20190528082104-30e424939505 h1:ooJvd+PTXxaHDJBP++saAcxinwBbOW/YJR7N4/Twbfk=
github.com/gin-contrib/multitemplate v0.0.0-20190528082104-30e424939505/go.mod h1:2tmLQ8sVzr2XKwquGd7zNq3zB6fGyjJL+47JoxoF8yM=
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
@@ -30,8 +28,8 @@ github.com/litao91/goldmark-mathjax v0.0.0-20200921072530-4c5dae64834a/go.mod h1
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/microcosm-cc/bluemonday v1.0.3 h1:EjVH7OqbU219kdm8acbveoclh2zZFqPJTJw6VUlTLAQ=
github.com/microcosm-cc/bluemonday v1.0.3/go.mod h1:8iwZnFn2CDDNZ0r6UXhF4xawGvzaqzCRa1n3/lO3W2w=
github.com/microcosm-cc/bluemonday v1.0.5 h1:cF59UCKMmmUgqN1baLvqU/B1ZsMori+duLVTLpgiG3w=
github.com/microcosm-cc/bluemonday v1.0.5/go.mod h1:8iwZnFn2CDDNZ0r6UXhF4xawGvzaqzCRa1n3/lO3W2w=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=

View File

@@ -112,6 +112,10 @@ function retagContent() {
window.MathJax.typeset();
}
// Reapply syntax highlight
hljs.initHighlighting.called = false;
hljs.initHighlighting();
// Re-render Mermaid diagrams
mermaid.init();
}

View File

@@ -13,6 +13,8 @@ def browser():
options.add_argument("--headless")
options.add_argument("window-size=1920,1080")
browser = webdriver.Chrome(options=options)
browser.get(INDEX_URL)
assert_no_javascript_errors(browser)
yield browser
browser.quit()
@@ -32,15 +34,7 @@ def assert_no_javascript_errors(browser):
)
def test_index_should_redirect_to_edit(browser):
browser.get(INDEX_URL)
assert "/edit" in browser.current_url
def test_should_edit(browser):
browser.get(INDEX_URL)
assert_no_javascript_errors(browser)
# Type a new note
user_input = browser.find_element_by_id("userInput")
user_input.clear()
@@ -81,9 +75,6 @@ def test_should_edit(browser):
def test_upload(browser):
browser.get(INDEX_URL)
assert_no_javascript_errors(browser)
# Upload a file
upload_file(browser, "readme.txt", "src/python/assets/readme.txt")
sleep(1)
@@ -91,3 +82,37 @@ def test_upload(browser):
# Should create a link
browser.find_element_by_link_text("readme.txt")
def test_code_highlight(browser):
# Type some source code
user_input = browser.find_element_by_id("userInput")
user_input.clear()
user_input.send_keys(
"```python\n"
"def hello_world():\n"
" print('Hello')\n"
"```\n"
)
sleep(1)
assert_no_javascript_errors(browser)
# Should create highlighted elements
browser.find_element_by_css_selector(".hljs-title")
def test_mermaid(browser):
# Draw a diagram
user_input = browser.find_element_by_id("userInput")
user_input.clear()
user_input.send_keys(
'<div class="mermaid">\n'
'graph TD\n'
' hello --> world\n'
'</div>\n'
)
sleep(1)
assert_no_javascript_errors(browser)
# Should create highlighted elements
browser.find_element_by_tag_name("svg")