Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pre-release]: Tracking changes for pre-release of v4.11.0 #1024

Merged
merged 48 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
eea41a1
feat(chore): configure pre-commit hook (#983)
jamesgeorge007 Dec 19, 2019
daf54b9
There are currently {three=>four} themes available. (#892)
dtinth Dec 20, 2019
808123b
Added a redirect for images to show up in Amplify (#918)
rasensio Dec 20, 2019
8416275
docs: about cache (#854)
QingWei-Li Dec 22, 2019
5b77b0f
fix: stage modified files as part of pre-commit hook (#985)
jamesgeorge007 Dec 22, 2019
7d0c164
chore: removed the escaping of the name of sidebar
anikethsaha Dec 28, 2019
d60fb7d
Merge pull request #991 from anikethsaha/develop
anikethsaha Dec 28, 2019
67a981b
update docs for the `name` config option
trusktr Dec 29, 2019
157973c
Merge pull request #992 from docsifyjs/update-name-doc
anikethsaha Dec 30, 2019
db97a1d
Eslint fixes for v4x (#989)
giulioambrogi Dec 30, 2019
7fb50b9
strip indent when embedding code fragment
Fs02 Jan 5, 2020
45d0c3a
chore: added github Actions for CI
anikethsaha Jan 8, 2020
336908f
chore: CI workflow fixes
anikethsaha Jan 8, 2020
b3eced3
Merge pull request #1000 from docsifyjs/github-action-ci
anikethsaha Jan 8, 2020
4f48679
Merge pull request #996 from Fs02/strip-indent-when-embedding-code
anikethsaha Jan 11, 2020
efbea24
feat: Add a prepare script.
trusktr Jan 25, 2020
e566e9c
Merge branch 'develop' into prepare-script
trusktr Jan 28, 2020
07f6edc
Merge pull request #1010 from docsifyjs/prepare-script
trusktr Jan 28, 2020
a213f98
chore(GH-action): using ubuntu 16 and removed node 8 from CI
anikethsaha Jan 30, 2020
0e54ea1
[Test] : e2e tests using cypress (#999)
anikethsaha Jan 30, 2020
4419611
Add undefined check for postcontent in search plugin
Neatoro Jan 16, 2020
74ee01c
chore: add config (#1014)
QingWei-Li Feb 3, 2020
fc6e3ee
chore(stale): added enhancement label to exemptlabels
anikethsaha Feb 4, 2020
b83622e
chore(stale): added bug label to exemptlabels
anikethsaha Feb 4, 2020
2928eb7
Ensure autoHeader dom result is similar to parsed H1 (#811)
cyrilf Feb 4, 2020
90a35ab
Fix #895 (#896)
bgpat Feb 5, 2020
6184e50
fix: searching table content
sy-records Feb 7, 2020
724ac02
feat: added capability to add css class and id to images + links + re…
arelstone Feb 8, 2020
92c29ac
chore(docs) : removed FOSSA badge
anikethsaha Feb 9, 2020
6e9911c
update: .markdown-section max-width 800px to 80% (#1017)
jhoneybee Feb 12, 2020
d798a12
changed the CDN from unpkg to jsDelivr #1020 (#1022)
orama254 Feb 12, 2020
0e4cdad
fix config initialization and coercion (#861)
L3au Feb 13, 2020
b3d9b96
fix: emojis in titles not working correctly and update (#1016)
Koooooo-7 Feb 14, 2020
5f7464a
chore: migrate CI to github, refactore CI and npm scripts, linting fi…
anikethsaha Feb 14, 2020
2639be7
chore(readme): added CI badges and fixed the logo issue
anikethsaha Feb 14, 2020
a111df9
chore: documented __colon__ tip (#1025)
anikethsaha Feb 14, 2020
75c72e9
chore: added new linter config (#1028)
anikethsaha Feb 20, 2020
b7547f1
feat: new option hideSidebar (#1026)
anikethsaha Feb 20, 2020
c83b7e3
chore(CI): added snyk action (#1030)
anikethsaha Feb 22, 2020
dc43d3c
feat: added dark mode to docs closes #1031
anikethsaha Feb 23, 2020
562cd7c
chore(CI): deleting snyk action as github doesnt allow tokens to forks
anikethsaha Mar 4, 2020
b53ea1e
Adds option to specify an header height (#1045)
leorossi Mar 9, 2020
291c99b
Migrate relative links to absolute in embedded markdown (#867)
aenniw Mar 9, 2020
0f1749c
chore(scroll): smarter scroll behavior (#744)
solymosi Mar 9, 2020
5d541dd
improve basic layout style (#884)
kidonng Mar 9, 2020
78290b2
fix: upgrade docsify from 4.9.4 to 4.10.2 (#1054)
snyk-bot Mar 9, 2020
39ebd73
fix: upgrade medium-zoom from 1.0.4 to 1.0.5
snyk-bot Mar 5, 2020
9981c43
fix: upgrade prismjs from 1.17.1 to 1.19.0
snyk-bot Mar 5, 2020
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
Prev Previous commit
Next Next commit
feat: added capability to add css class and id to images + links + re…
…factoring (#820)

* method extraction

* support for CSS class and id

* Update package.json

* Added tests for refactored render-methods

* minor refactoring
  • Loading branch information
arelstone authored Feb 8, 2020
commit 724ac024ddfc28e93d8b5dd909e722747286fa00
1 change: 0 additions & 1 deletion cypress/integration/sidebar/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ context('sidebar.configurations', () => {
'set-target-attribute-for-link',
'disable-link',
'github-task-lists',
'image-resizing',
'customise-id-for-headings',
'markdown-in-html-tag'
]
Expand Down
Binary file not shown.
17 changes: 16 additions & 1 deletion docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
- [ ] bim
- [ ] lim

## Image resizing
## Image

### Resizing

```md
![logo](https://docsify.js.org/_media/icon.svg ':size=WIDTHxHEIGHT')
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
![logo](https://docsify.js.org/_media/icon.svg ':size=100')

Expand All @@ -96,6 +99,18 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
![logo](https://docsify.js.org/_media/icon.svg ':size=10%')

### Customise class

```md
![logo](https://docsify.js.org/_media/icon.svg ':class=someCssClass')
```

### Customise ID

```md
![logo](https://docsify.js.org/_media/icon.svg ':id=someCssId')
```

## Customise ID for headings

```md
Expand Down
41 changes: 30 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/docsify-server-renderer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

133 changes: 15 additions & 118 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import marked from 'marked'
import Prism from 'prismjs'
import { helper as helperTpl, tree as treeTpl } from './tpl'
import { tree as treeTpl } from './tpl'
import { genTree } from './gen-tree'
import { slugify } from './slugify'
import { emojify } from './emojify'
import { isAbsolutePath, getPath, getParentPath } from '../router/util'
import { isFn, merge, cached, isPrimitive } from '../util/core'

// See https://github.com/PrismJS/prism/pull/1367
import 'prismjs/components/prism-markup-templating'
import { imageCompiler } from './compiler/image'
import { highlightCodeCompiler } from './compiler/code'
import { paragraphCompiler } from './compiler/paragraph'
import { taskListCompiler } from './compiler/taskList'
import { taskListItemCompiler } from './compiler/taskListItem'
import { linkCompiler } from './compiler/link'
import marked from 'marked'

const cachedLinks = {}

Expand Down Expand Up @@ -189,7 +191,7 @@ export class Compiler {

_initRenderer() {
const renderer = new marked.Renderer()
const { linkTarget, linkRel, router, contentBase } = this
const { linkTarget, router, contentBase } = this
const _self = this
const origin = {}

Expand Down Expand Up @@ -224,117 +226,12 @@ export class Compiler {
return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${str}</span></a></h${level}>`
}

// Highlight code
origin.code = renderer.code = function (code, lang = '') {
code = code.replace(/@DOCSIFY_QM@/g, '`')
const hl = Prism.highlight(
code,
Prism.languages[lang] || Prism.languages.markup
)

return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
}

origin.link = renderer.link = function (href, title = '', text) {
let attrs = ''

const { str, config } = getAndRemoveConfig(title)
title = str

if (
!isAbsolutePath(href) &&
!_self._matchNotCompileLink(href) &&
!config.ignore
) {
if (href === _self.config.homepage) {
href = 'README'
}

href = router.toURL(href, null, router.getCurrentPath())
} else {
attrs += href.indexOf('mailto:') === 0 ? '' : ` target="${linkTarget}"`
attrs += href.indexOf('mailto:') === 0 ? '' : (linkRel !== '' ? ` rel="${linkRel}"` : '')
}

if (config.target) {
attrs += ' target=' + config.target
}

if (config.disabled) {
attrs += ' disabled'
href = 'javascript:void(0)'
}

if (title) {
attrs += ` title="${title}"`
}

return `<a href="${href}"${attrs}>${text}</a>`
}

origin.paragraph = renderer.paragraph = function (text) {
let result
if (/^!&gt;/.test(text)) {
result = helperTpl('tip', text)
} else if (/^\?&gt;/.test(text)) {
result = helperTpl('warn', text)
} else {
result = `<p>${text}</p>`
}

return result
}

origin.image = renderer.image = function (href, title, text) {
let url = href
let attrs = ''

const { str, config } = getAndRemoveConfig(title)
title = str

if (config['no-zoom']) {
attrs += ' data-no-zoom'
}

if (title) {
attrs += ` title="${title}"`
}

const size = config.size
if (size) {
const sizes = size.split('x')
if (sizes[1]) {
attrs += 'width=' + sizes[0] + ' height=' + sizes[1]
} else {
attrs += 'width=' + sizes[0]
}
}

if (!isAbsolutePath(href)) {
url = getPath(contentBase, getParentPath(router.getCurrentPath()), href)
}

return `<img src="${url}"data-origin="${href}" alt="${text}"${attrs}>`
}

origin.list = renderer.list = function (body, ordered, start) {
const isTaskList = /<li class="task-list-item">/.test(body.split('class="task-list"')[0])
const isStartReq = start && start > 1
const tag = ordered ? 'ol' : 'ul'
const tagAttrs = [
(isTaskList ? 'class="task-list"' : ''),
(isStartReq ? `start="${start}"` : '')
].join(' ').trim()

return `<${tag} ${tagAttrs}>${body}</${tag}>`
}

origin.listitem = renderer.listitem = function (text) {
const isTaskItem = /^(<input.*type="checkbox"[^>]*>)/.test(text)
const html = isTaskItem ? `<li class="task-list-item"><label>${text}</label></li>` : `<li>${text}</li>`

return html
}
origin.code = highlightCodeCompiler({ renderer })
origin.link = linkCompiler({ renderer, router, linkTarget, compilerClass: _self })
origin.paragraph = paragraphCompiler({ renderer })
origin.image = imageCompiler({ renderer, contentBase, router })
origin.list = taskListCompiler({ renderer })
origin.listitem = taskListItemCompiler({ renderer })

renderer.origin = origin

Expand Down
10 changes: 10 additions & 0 deletions src/core/render/compiler/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Prism from 'prismjs'
// See https://github.com/PrismJS/prism/pull/1367
import 'prismjs/components/prism-markup-templating'

export const highlightCodeCompiler = ({ renderer }) => renderer.code = function (code, lang = '') {
const langOrMarkup = Prism.languages[lang] || Prism.languages.markup
const text = Prism.highlight(code.replace(/@DOCSIFY_QM@/g, '`'), langOrMarkup)

return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${text}</code></pre>`
}
Loading