-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 添加 chapterTextFilter 参数,用于处理 chapters 菜单中显示的文本;
- Loading branch information
1 parent
663fe66
commit 7d57fb1
Showing
21 changed files
with
341 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
section.section | ||
header.section__header | ||
h3#option-chapterTextFilter.section__h3 chapterTextFilter | ||
div.section__content | ||
h4.section__h4 Description | ||
dl.section__dl | ||
dt.section__dt Type: | ||
dd.section__dd Function | ||
dl.section__dl | ||
dt.section__dt Default: | ||
dd.section__dd null | ||
p 可选,API 文档中,正文的方法会添加参数等信息,例如:getChapters(headings, showCode, chapterTextFilter)。而在 chapters 导航菜单,我希望显示为 getChapters(),这时我们就可以借助 chapterTextFilter 回调函数。对原始的文本进行过滤,返回我们期望的 getChapters() 文本。 | ||
h4.section__h4 Parameters | ||
h5.section__h4 text | ||
dl.section__dl | ||
dt.section__dt Type: | ||
dd.section__dd String | ||
p chapterTextFilter() 回调函数有一个参数 text,返回的是当前 hx 标题中的文本。 | ||
pre.section__pre | ||
code.section__code. | ||
const defaults = Outline.DEFAULTS | ||
let outline | ||
|
||
defaults.selector = 'h2,h3' | ||
defaults.title = false | ||
defaults.showCode = false | ||
defaults.position = 'sticky' | ||
defaults.parentElement = '#aside' | ||
defaults.scrollElement = '#main' | ||
defaults.articleElement = '#article' | ||
defaults.homepage = './index.html' | ||
defaults.git = 'https://github.com/yaohaixiao/outline.js' | ||
defaults.tags = 'https://github.com/yaohaixiao/outline.js/tags' | ||
defaults.issues = 'https://github.com/yaohaixiao/outline.js/issues' | ||
defaults.print = { | ||
element: '#article', | ||
title: 'Outline.js' | ||
} | ||
defaults.chapterTextFilter = (text) => { | ||
return text.replace(/\(.*?\)/, '()') | ||
} | ||
outline = new Outline(Outline.DEFAULTS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ section.section | |
include afterScroll | ||
include afterSticky | ||
include afterToggle | ||
include chpaterTextFilter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
link(rel="preload" href="css/docs.min.css" as="style") | ||
link(rel="preload" href="js/docs.min.js" as="script") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.