Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Add support for Azure DevOps wikis #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<a href="https://mermaidjs.github.io" target="_blank">Mermaid</a>
language support to
<img src="https://github.githubassets.com/favicon.ico" width="16" height="16"/>
<a href="https://guides.github.com/features/mastering-markdown/" target="_blank">Github Markdown</a>.
<a href="https://guides.github.com/features/mastering-markdown/" target="_blank">Github Markdown</a>
and also <a href="https://docs.microsoft.com/en-us/azure/devops/project/wiki/markdown-guidance?view=azure-devops" target="_blank">Azure DevOps</a>.
</strong>
</p>
</div>
Expand Down Expand Up @@ -59,6 +60,10 @@
- [x] Markdown (`.md`) files (diff + published)
- [x] Gists - [Demo](https://gist.github.com/amercier/df2e07a994315d323e398120bdda3989)

### Supported Azure DevOps features

- [x] Wikis with code blocks

### Diagram types

#### Flowcharts
Expand Down
8 changes: 5 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "GitHub + Mermaid",
"version": "0.1.1",
"manifest_version": 2,
"description": "A browser extension for Chrome, Opera & Firefox that adds Mermaid language support to GitHub.",
"description": "A browser extension for Chrome, Opera & Firefox that adds Mermaid language support to GitHub and Azure DevOps.",
"icons": {
"16": "icons/icon-16.png",
"128": "icons/icon-128.png"
Expand All @@ -15,7 +15,8 @@
},
"permissions": [
"https://github.com/*",
"https://*.github.com/*"
"https://*.github.com/*",
"https://dev.azure.com/*"
],
"options_ui": {
"page": "options.html"
Expand All @@ -24,7 +25,8 @@
{
"matches": [
"https://github.com/*",
"https://*.github.com/*"
"https://*.github.com/*",
"https://dev.azure.com/*"
],
"js": [
"scripts/contentscript.js"
Expand Down
10 changes: 9 additions & 1 deletion src/scripts/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function processElement(source, id) {
}

/**
* Process all `pre[lang="mermaid"]` elements that don't have
* Process all `pre[lang="mermaid"]` or `pre[class="hljs"]` elements that don't have
* `[data-processed="true"]`.
* @param {Iterator<string>} idIterator Id iterator
*/
Expand All @@ -118,6 +118,14 @@ function processUnprocessedElements(idIterator) {
source.setAttribute('data-processed', 'true')
const target = processElement(source, idIterator.next().value)
})

// Azure DevOps Wikis don't provide the language for mermaid, but do provide language
// for other known languages such as cpp. We can select code blocks without a language defined
const selectorAzure = 'pre[class="hljs"]>code:not([class]):not([data-processed])';
[...document.querySelectorAll(selectorAzure)].forEach(source => {
source.setAttribute('data-processed', 'true')
const target = processElement(source, idIterator.next().value)
})
}

// Mermaid setup
Expand Down