Browse Source

Merge pull request #14227 from overleaf/mj-table-gen-booktabs

[visual] Support booktabs horizontal borders

GitOrigin-RevId: 9e59341b514c667fbba4154e6316274f9e42db3d
Mathias Jakobsen 3 năm trước cách đây
mục cha
commit
63b09c3da3

+ 1 - 1
services/web/frontend/js/features/source-editor/components/table-generator/utils.ts

@@ -71,7 +71,7 @@ const isRowSeparator = (node: SyntaxNode, state: EditorState) =>
 
 const isHLine = (node: SyntaxNode) =>
   node.type.is('Command') &&
-  Boolean(node.getChild('KnownCommand')?.getChild('HLine'))
+  Boolean(node.getChild('KnownCommand')?.getChild('HorizontalLine'))
 
 type Position = {
   from: number

+ 7 - 4
services/web/frontend/js/features/source-editor/lezer-latex/latex.grammar

@@ -90,8 +90,11 @@
     AuthorCtrlSeq,
     MaketitleCtrlSeq,
     TextColorCtrlSeq,
-    ColorBoxCtrlSeq
-    HLineCtrlSeq
+    ColorBoxCtrlSeq,
+    HLineCtrlSeq,
+    TopRuleCtrlSeq,
+    MidRuleCtrlSeq,
+    BottomRuleCtrlSeq
 }
 
 @external specialize {EnvName} specializeEnvName from "./tokens.mjs" {
@@ -338,8 +341,8 @@ KnownCommand {
     Maketitle {
         MaketitleCtrlSeq optionalWhitespace?
     } |
-    HLine {
-        HLineCtrlSeq optionalWhitespace?
+    HorizontalLine {
+        (HLineCtrlSeq | TopRuleCtrlSeq | MidRuleCtrlSeq | BottomRuleCtrlSeq) optionalWhitespace?
     }
 }
 

+ 6 - 0
services/web/frontend/js/features/source-editor/lezer-latex/tokens.mjs

@@ -73,6 +73,9 @@ import {
   TextColorCtrlSeq,
   ColorBoxCtrlSeq,
   HLineCtrlSeq,
+  TopRuleCtrlSeq,
+  MidRuleCtrlSeq,
+  BottomRuleCtrlSeq,
 } from './latex.terms.mjs'
 
 function nameChar(ch) {
@@ -622,6 +625,9 @@ const otherKnowncommands = {
   '\\textcolor': TextColorCtrlSeq,
   '\\colorbox': ColorBoxCtrlSeq,
   '\\hline': HLineCtrlSeq,
+  '\\toprule': TopRuleCtrlSeq,
+  '\\midrule': MidRuleCtrlSeq,
+  '\\bottomrule': BottomRuleCtrlSeq,
 }
 // specializer for control sequences
 // return new tokens for specific control sequences