Skip to content

Commit

Permalink
Fixes #1115 list block highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
seballot committed Jan 5, 2024
1 parent c9d89b2 commit 90f9023
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions tools/aceditor/presentation/javascripts/mode-yeswiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ ace.define('ace/mode/yeswiki_highlight_rules', ['require', 'exports', 'module',
token: 'constant.hr',
regex: '^[-]{3,50}$',
next: 'allowBlock'
}, { // list
}, { // list ( - or 1. )
token: 'markup.list',
regex: '^\\s{1,3}(?:-|\\d+\\.)\\s+',
next: 'listblock-start'
}, markdownLink, {
include: 'basic',
noEscape: true
Expand Down Expand Up @@ -114,23 +113,6 @@ ace.define('ace/mode/yeswiki_highlight_rules', ['require', 'exports', 'module',
regex: '\\}\\}',
next: 'start'
}],
'listblock-start': [{
token: 'support.variable',
regex: /(?:\[[ x]\])?/,
next: 'listblock'
}],
listblock: [{ // Lists only escape on completely blank lines.
token: 'empty_line',
regex: '^$',
next: 'start'
}, { // list
token: 'markup.list',
regex: '^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+',
next: 'listblock-start'
}, markdownLink, {
include: 'basic',
noEscape: true
}],
'pre-start': [
{ // pre //
token: 'markup.pre',
Expand Down Expand Up @@ -504,13 +486,14 @@ ace.define('ace/mode/yeswiki', ['require', 'exports', 'module', 'ace/lib/oop', '
this.$quotes = { '"': '"', '`': '`' }

this.getNextLineIndent = function(state, line, tab) {
if (state == 'listblock') {
const match = /^(\s*)(?:([-+*])|(\d+)\.)(\s+)/.exec(line)
if (!match) return ''
const listMatch = /^(\s*)(?:([-+*])|(\d+)\.)(\s+)/.exec(line)
// For lists, add the - on next line, or increment the number for ordered list 1. 2.
if (listMatch) {
let marker = match[2]
if (!marker) marker = `${parseInt(match[3], 10) + 1}.`
return match[1] + marker + match[4]
}
// Next mine use same identation
return this.$getIndent(line)
}
this.$id = 'ace/mode/yeswiki'
Expand Down

1 comment on commit 90f9023

@mrflos
Copy link
Contributor

@mrflos mrflos commented on 90f9023 Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trop cool, merci <3 (j'aurais jamais trouvé...)

Please sign in to comment.