Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Luc Bourdot
codimd
Commits
aa5a50fa
Unverified
Commit
aa5a50fa
authored
Nov 01, 2019
by
Yukai Huang
Committed by
GitHub
Nov 01, 2019
Browse files
Merge pull request #1306 from hackmdio/feature/configurable-break-style
Configurable default break style
parents
f871eff2
75ee5ad2
Changes
6
Hide whitespace changes
Inline
Side-by-side
lib/config/default.js
View file @
aa5a50fa
...
...
@@ -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.
...
...
lib/config/environment.js
View file @
aa5a50fa
...
...
@@ -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
}
lib/web/statusRouter.js
View file @
aa5a50fa
...
...
@@ -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
({
...
...
public/js/extra.js
View file @
aa5a50fa
...
...
@@ -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
,
...
...
public/js/lib/common/constant.ejs
View file @
aa5a50fa
...
...
@@ -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 %>'
public/js/slide.js
View file @
aa5a50fa
...
...
@@ -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
()
||
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment