Skip to content

Commit

Permalink
Merge pull request #3 from kernoeb/puml
Browse files Browse the repository at this point in the history
  • Loading branch information
kernoeb authored Aug 25, 2022
2 parents 1d804ab + 9092114 commit c12cde4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/tutorials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ This is a `README` in a subdirectory
This is also [cool](/usecase/cool)

And check this [test](documentation/test.md)

```plantuml
[[!include ./documentation/example.puml]]
```
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
}
</script>
<!-- Docsify v4 -->
<script src="./resources/js/docsify.js"></script>
<script src="./resources/js/all.js"></script>
</body>
</html>
1 change: 0 additions & 1 deletion resources/js/docsify-plantuml.min.js

This file was deleted.

1 change: 1 addition & 0 deletions resources/js/docsify-puml.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const dir = path.resolve(__dirname, '../resources/js')
if (!fs.existsSync(dir)) fsExtra.mkdirp(dir)

const jsFiles = fs.readdirSync(path.resolve(__dirname, '../resources/js'))
.filter(file => file !== 'all.js')
.filter(file => !['all.js', 'docsify.js'].includes(file))
.map(file => path.resolve(__dirname, '../resources/js/' + file))
.filter(file => file.endsWith('.js'))

Expand Down
13 changes: 12 additions & 1 deletion src/process-files-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ module.exports = ({ pathToStatic }) => ({ content, name }) => {
const dir = path.dirname(name)
const dirWithStatic = path.resolve(process.cwd(), pathToStatic)

markdownLinkExtractor(content)
// match all [[!include .*]]
let includeMatches = []
const includeRegex = /\[\[!include\s+(.*)]]/gm
const tmpMatches = markdown.match(includeRegex)
if (tmpMatches?.length) {
includeMatches = tmpMatches
.map(v => v.trim()).filter(Boolean)
.map(match => match.replace('[[!include ', '').replace(']]', '').trim())
.filter(Boolean)
}

markdownLinkExtractor(content).concat(includeMatches)
.filter(link => !isUrl(link))
.filter(isGoodFile) // check if it's an image, a puml, etc.
.map(link => ({ origin: link, processed: path.resolve(dir, link) }))
Expand Down

0 comments on commit c12cde4

Please # to comment.