Просмотр исходного кода

[cm6] Include affiliation in document preamble (#14824)

* [cm6] Include affiliation in document preamble

* add affil command

* Add mapping to attributeValue

---------

Co-authored-by: Alf Eaton <alf.eaton@overleaf.com>
GitOrigin-RevId: 6034e07bc5fec23ea704d820acbbe4e77caba651
Domagoj Kriskovic 2 лет назад
Родитель
Сommit
f7cf7b9028

+ 8 - 0
services/web/frontend/js/features/source-editor/extensions/visual/atomic-decorations.ts

@@ -217,6 +217,14 @@ export const atomicDecorations = (options: Options) => {
             preamble.authors.push({ node, content })
             preamble.to = nodeRef.node.to
           }
+        } else if (
+          nodeRef.node.type.is('Affil') ||
+          nodeRef.node.type.is('Affiliation')
+        ) {
+          const node = nodeRef.node.getChild('TextArgument')
+          if (node) {
+            preamble.to = nodeRef.node.to
+          }
         }
 
         if (nodeRef.type.is('$Environment')) {

+ 3 - 0
services/web/frontend/js/features/source-editor/languages/latex/latex-language.ts

@@ -178,6 +178,9 @@ export const LaTeXLanguage = LRLanguage.define({
         Comment: t.comment,
         'UsePackage/OptionalArgument/ShortOptionalArg/Normal': t.attributeValue,
         'UsePackage/ShortTextArgument/ShortArg/Normal': t.tagName,
+        'Affiliation/OptionalArgument/ShortOptionalArg/Normal':
+          t.attributeValue,
+        'Affil/OptionalArgument/ShortOptionalArg/Normal': t.attributeValue,
         'LiteralArgContent VerbContent VerbatimContent LstInlineContent':
           t.string,
         'NewCommand/LiteralArgContent': t.typeName,

+ 8 - 0
services/web/frontend/js/features/source-editor/lezer-latex/latex.grammar

@@ -88,6 +88,8 @@
     BibliographyCtrlSeq,
     BibliographyStyleCtrlSeq,
     AuthorCtrlSeq,
+    AffilCtrlSeq,
+    AffiliationCtrlSeq,
     MaketitleCtrlSeq,
     TextColorCtrlSeq,
     ColorBoxCtrlSeq,
@@ -241,6 +243,12 @@ KnownCommand {
     Author {
         AuthorCtrlSeq optionalWhitespace? OptionalArgument? optionalWhitespace? TextArgument
     } |
+    Affil {
+        AffilCtrlSeq optionalWhitespace? OptionalArgument? optionalWhitespace? TextArgument
+    } |
+    Affiliation {
+        AffiliationCtrlSeq optionalWhitespace? OptionalArgument? optionalWhitespace? TextArgument
+    } |
     DocumentClass {
         DocumentClassCtrlSeq optionalWhitespace? OptionalArgument?
         DocumentClassArgument { ShortTextArgument }

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

@@ -24,6 +24,8 @@ import {
   HboxCtrlSeq,
   TitleCtrlSeq,
   AuthorCtrlSeq,
+  AffilCtrlSeq,
+  AffiliationCtrlSeq,
   DocumentClassCtrlSeq,
   UsePackageCtrlSeq,
   HrefCtrlSeq,
@@ -589,6 +591,8 @@ const otherKnowncommands = {
   '\\hbox': HboxCtrlSeq,
   '\\title': TitleCtrlSeq,
   '\\author': AuthorCtrlSeq,
+  '\\affil': AffilCtrlSeq,
+  '\\affiliation': AffiliationCtrlSeq,
   '\\documentclass': DocumentClassCtrlSeq,
   '\\usepackage': UsePackageCtrlSeq,
   '\\href': HrefCtrlSeq,