Unverified Commit aa5a50fa authored by Yukai Huang's avatar Yukai Huang Committed by GitHub
Browse files

Merge pull request #1306 from hackmdio/feature/configurable-break-style

Configurable default break style
parents f871eff2 75ee5ad2
......@@ -164,6 +164,7 @@ module.exports = {
allowGravatar: true,
allowPDFExport: true,
openID: false,
defaultUseHardbreak: true,
// linkifyHeaderStyle - How is a header text converted into a link id.
// Header Example: "3.1. Good Morning my Friend! - Do you have 5$?"
// * 'keep-case' is the legacy CodiMD value.
......
......@@ -137,5 +137,6 @@ module.exports = {
allowGravatar: toBooleanConfig(process.env.CMD_ALLOW_GRAVATAR),
allowPDFExport: toBooleanConfig(process.env.CMD_ALLOW_PDF_EXPORT),
openID: toBooleanConfig(process.env.CMD_OPENID),
defaultUseHardbreak: toBooleanConfig(process.env.CMD_DEFAULT_USE_HARD_BREAK),
linkifyHeaderStyle: process.env.CMD_LINKIFY_HEADER_STYLE
}
......@@ -100,6 +100,7 @@ statusRouter.get('/config', function (req, res) {
plantumlServer: config.plantuml.server,
DROPBOX_APP_KEY: config.dropbox.appKey,
allowedUploadMimeTypes: config.allowedUploadMimeTypes,
defaultUseHardbreak: config.defaultUseHardbreak,
linkifyHeaderStyle: config.linkifyHeaderStyle
}
res.set({
......
......@@ -195,7 +195,7 @@ export function isValidURL (str) {
export function parseMeta (md, edit, view, toc, tocAffix) {
let lang = null
let dir = null
let breaks = true
let breaks = window.defaultUseHardbreak
if (md && md.meta) {
const meta = md.meta
lang = meta.lang
......@@ -225,10 +225,10 @@ export function parseMeta (md, edit, view, toc, tocAffix) {
tocAffix.removeAttr('dir')
}
// breaks
if (typeof breaks === 'boolean' && !breaks) {
md.options.breaks = false
if (typeof breaks === 'boolean') {
md.options.breaks = breaks
} else {
md.options.breaks = true
md.options.breaks = window.defaultUseHardbreak
}
}
......@@ -1030,7 +1030,7 @@ function highlightRender (code, lang) {
export const md = markdownit('default', {
html: true,
breaks: true,
breaks: window.defaultUseHardbreak,
langPrefix: '',
linkify: true,
typographer: true,
......
......@@ -6,6 +6,8 @@ window.plantumlServer = '<%- plantumlServer %>'
window.allowedUploadMimeTypes = <%- JSON.stringify(allowedUploadMimeTypes) %>
window.defaultUseHardbreak = <%- defaultUseHardbreak %>
window.linkifyHeaderStyle = '<%- linkifyHeaderStyle %>'
window.DROPBOX_APP_KEY = '<%- DROPBOX_APP_KEY %>'
......@@ -49,6 +49,15 @@ const deps = [{
}
}]
// options from yaml meta
const meta = JSON.parse($('#meta').text())
// breaks
if (typeof meta.breaks === 'boolean') {
md.options.breaks = meta.breaks
} else {
md.options.breaks = window.defaultUseHardbreak
}
const slideOptions = {
separator: '^(\r\n?|\n)---(\r\n?|\n)$',
verticalSeparator: '^(\r\n?|\n)----(\r\n?|\n)$'
......@@ -70,8 +79,6 @@ const defaultOptions = {
dependencies: deps
}
// options from yaml meta
const meta = JSON.parse($('#meta').text())
var options = meta.slideOptions || {}
if (Object.hasOwnProperty.call(options, 'spotlight')) {
......@@ -103,12 +110,6 @@ if (meta.dir && typeof meta.dir === 'string' && meta.dir === 'rtl') {
} else {
options.rtl = false
}
// breaks
if (typeof meta.breaks === 'boolean' && !meta.breaks) {
md.options.breaks = false
} else {
md.options.breaks = true
}
// options from URL query string
const queryOptions = Reveal.getQueryHash() || {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment