Skip to content
Merged
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
1 change: 1 addition & 0 deletions lib/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions lib/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions lib/web/statusRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
10 changes: 5 additions & 5 deletions public/js/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions public/js/lib/common/constant.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>'
17 changes: 9 additions & 8 deletions public/js/slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)$'
Expand All @@ -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')) {
Expand Down Expand Up @@ -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() || {}
Expand Down