Skip to content

Commit

Permalink
add possibility to register showdown extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Guseyn committed Nov 24, 2024
1 parent 2f30779 commit d2f82a5
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 72 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ehtml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ jobs:
- run: npm run build

release:
if: github.event_name == 'push'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Check commit message format
id: check_commit
run: |
if [[ "${{ github.event.head_commit.message }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "commit_message_format=valid" >> $GITHUB_ENV
else
echo "commit_message_format=invalid" >> $GITHUB_ENV
- name: Create GitHub Release
if: env.commit_message_format == 'valid'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
58 changes: 29 additions & 29 deletions ehtml.bundle.min.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions ehtml.light.bundle.min.js

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions examples/static/js/ehtml.bundle.min.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions examples/static/js/ehtml.light.bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/E/e-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (!LIGHT_VERSION) {
}

module.exports = (node) => {
const extensions = []
const extensions = window.__ehtmlShowdownExtensions__ || []
if (node.getAttribute('data-apply-code-highlighting') && showdownHighlight) {
extensions.push(
showdownHighlight({
Expand Down
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const observeNodeWithItsChildNodes = require('./observeNodeWithItsChildNodes')
const turnEhtmlMutationObserverOn = require('./turnEhtmlMutationObserverOn')
const turnEhtmlMutationObserverOff = require('./turnEhtmlMutationObserverOff')
const registerShowdownExtension = require('./registerShowdownExtension')
require('./actions/exports')

window.__ehtmlState__ = window.__ehtmlState__ || {}
window.__ehtmlCustomElements__ = window.__ehtmlCustomElements__ || {}
window.__ehtmlShowdownExtensions__ = window.__ehtmlShowdownExtensions__ || []

window.ehtmlMutationObserver = new MutationObserver(
(mutationsList, observer) => {
Expand All @@ -25,3 +27,4 @@ turnEhtmlMutationObserverOn(

window.turnEhtmlMutationObserverOn = turnEhtmlMutationObserverOn
window.turnEhtmlMutationObserverOff = turnEhtmlMutationObserverOff
window.registerShowdownExtension = registerShowdownExtension
6 changes: 6 additions & 0 deletions src/registerShowdownExtension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const showdown = require('showdown')

module.exports = function(name, extensionFunction) {

Check failure on line 3 in src/registerShowdownExtension.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing space before function parentheses
const customShowdownExtension = showdown.extension(name, extensionFunction)

Check failure on line 4 in src/registerShowdownExtension.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'customShowdownExtension' is assigned a value but never used
window.__ehtmlShowdownExtensions__.push(name)
}

0 comments on commit d2f82a5

Please # to comment.