mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-07 08:09:01 +02:00
Merge pull request #14245 from overleaf/mj-linebreak-arguments
[lezer+visual] Allow optional arguments for line breaks GitOrigin-RevId: e59a7c9a2efacc8a0fde887736899bbcbb52a4bc
This commit is contained in:
committed by
Copybot
parent
261645dd77
commit
52e813985d
@@ -66,8 +66,9 @@ function parseColumnSpecifications(specification: string): ColumnDefinition[] {
|
||||
return columns
|
||||
}
|
||||
|
||||
const isRowSeparator = (node: SyntaxNode, state: EditorState) =>
|
||||
node.type.is('Command') && state.sliceDoc(node.from, node.to) === '\\\\'
|
||||
const isRowSeparator = (node: SyntaxNode) =>
|
||||
node.type.is('Command') &&
|
||||
Boolean(node.getChild('KnownCtrlSym')?.getChild('LineBreak'))
|
||||
|
||||
const isHLine = (node: SyntaxNode) =>
|
||||
node.type.is('Command') &&
|
||||
@@ -133,7 +134,7 @@ function parseTabularBody(
|
||||
currentChild;
|
||||
currentChild = currentChild.nextSibling
|
||||
) {
|
||||
if (isRowSeparator(currentChild, state)) {
|
||||
if (isRowSeparator(currentChild)) {
|
||||
const lastRow = getLastRow()
|
||||
body.rows.push({
|
||||
cells: [],
|
||||
|
||||
+10
-6
@@ -794,13 +794,17 @@ export const atomicDecorations = (options: Options) => {
|
||||
}).range(nodeRef.from, nodeRef.to)
|
||||
)
|
||||
}
|
||||
} else if (nodeRef.type.is('LineBreakCtrlSym')) {
|
||||
} else if (nodeRef.type.is('LineBreak')) {
|
||||
// line break
|
||||
decorations.push(
|
||||
Decoration.replace({
|
||||
widget: new IndicatorWidget('\u21A9'),
|
||||
}).range(nodeRef.from, nodeRef.to)
|
||||
)
|
||||
const optionalArgument = nodeRef.node.getChild('OptionalArgument')
|
||||
if (!optionalArgument || shouldDecorate(state, optionalArgument)) {
|
||||
decorations.push(
|
||||
Decoration.replace({
|
||||
widget: new IndicatorWidget('\u21A9'),
|
||||
}).range(nodeRef.from, nodeRef.to)
|
||||
)
|
||||
}
|
||||
return false
|
||||
} else if (nodeRef.type.is('Caption')) {
|
||||
if (shouldDecorate(state, nodeRef)) {
|
||||
// a caption
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
import { EditorState } from '@codemirror/state'
|
||||
import { SyntaxNode } from '@lezer/common'
|
||||
import { LineBreakCtrlSym } from '../../../lezer-latex/latex.terms.mjs'
|
||||
|
||||
const isUnknownCommandWithName = (
|
||||
node: SyntaxNode,
|
||||
@@ -92,7 +91,7 @@ export function typesetNodeIntoElement(
|
||||
// ignoring these commands
|
||||
from = childNode.to
|
||||
return false
|
||||
} else if (childNode.type.is(LineBreakCtrlSym)) {
|
||||
} else if (childNode.type.is('LineBreak')) {
|
||||
ancestor().appendChild(document.createElement('br'))
|
||||
from = childNode.to
|
||||
}
|
||||
|
||||
@@ -360,7 +360,9 @@ Command {
|
||||
}
|
||||
|
||||
KnownCtrlSym {
|
||||
LineBreakCtrlSym
|
||||
LineBreak {
|
||||
LineBreakCtrlSym OptionalArgument?
|
||||
}
|
||||
}
|
||||
|
||||
textBase {
|
||||
|
||||
Reference in New Issue
Block a user