From 8b0f0502205a3863f4b16aedacc4b49982ccf176 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 15 Mar 2022 05:47:17 +0900 Subject: [PATCH 1/6] Markdown: ues vString API more Signed-off-by: Masatake YAMATO --- parsers/markdown.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/parsers/markdown.c b/parsers/markdown.c index f8b664a3a3..9925aab097 100644 --- a/parsers/markdown.c +++ b/parsers/markdown.c @@ -231,15 +231,14 @@ static void findMarkdownTags (void) { startSourceLineNumber = getSourceLineNumber (); startLineNumber = getInputLineNumber (); - vStringClear (codeLang); - vStringCatS (codeLang, (const char *)(line + pos + nSame)); + vStringCopyS (codeLang, (const char *)(line + pos + nSame)); vStringStripLeading (codeLang); vStringStripTrailing (codeLang); } else { long endLineNumber = getInputLineNumber () - 1; - if (codeLang->size > 0) + if (vStringLength (codeLang) > 0) makePromise (vStringValue (codeLang), startLineNumber, 0, endLineNumber, 0, startSourceLineNumber); } From cfd6b00dc881fa21e194dc1e4ff151fc18bfbc27 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 15 Mar 2022 06:13:46 +0900 Subject: [PATCH 2/6] Markdown: extract footnotes Signed-off-by: Masatake YAMATO --- .../parser-markdown.r/footnotes.d/args.ctags | 2 ++ .../footnotes.d/expected.tags | 2 ++ Units/parser-markdown.r/footnotes.d/input.md | 12 ++++++++ parsers/markdown.c | 29 +++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 Units/parser-markdown.r/footnotes.d/args.ctags create mode 100644 Units/parser-markdown.r/footnotes.d/expected.tags create mode 100644 Units/parser-markdown.r/footnotes.d/input.md diff --git a/Units/parser-markdown.r/footnotes.d/args.ctags b/Units/parser-markdown.r/footnotes.d/args.ctags new file mode 100644 index 0000000000..e0622cb47b --- /dev/null +++ b/Units/parser-markdown.r/footnotes.d/args.ctags @@ -0,0 +1,2 @@ +--sort=no +--fields=+nK diff --git a/Units/parser-markdown.r/footnotes.d/expected.tags b/Units/parser-markdown.r/footnotes.d/expected.tags new file mode 100644 index 0000000000..c7e574636a --- /dev/null +++ b/Units/parser-markdown.r/footnotes.d/expected.tags @@ -0,0 +1,2 @@ +1 input.md /^[^1]: This is the first footnote.$/;" footnote line:4 +bignote input.md /^[^bignote]: Here's one with multiple paragraphs and code.$/;" footnote line:6 diff --git a/Units/parser-markdown.r/footnotes.d/input.md b/Units/parser-markdown.r/footnotes.d/input.md new file mode 100644 index 0000000000..10f630cb99 --- /dev/null +++ b/Units/parser-markdown.r/footnotes.d/input.md @@ -0,0 +1,12 @@ + +Here's a simple footnote,[^1] and here's a longer one.[^bignote] + +[^1]: This is the first footnote. + +[^bignote]: Here's one with multiple paragraphs and code. + + Indent paragraphs to include them in the footnote. + + `{ my code }` + + Add as many paragraphs as you like. diff --git a/parsers/markdown.c b/parsers/markdown.c index 9925aab097..db02b462fc 100644 --- a/parsers/markdown.c +++ b/parsers/markdown.c @@ -10,6 +10,9 @@ * This module contains functions for generating tags for markdown files. * * This parser was based on the asciidoc parser. + * + * Extended syntax like footnotes is described in + * https://www.markdownguide.org/extended-syntax/ */ /* @@ -41,6 +44,7 @@ typedef enum { K_LEVEL4SECTION, K_LEVEL5SECTION, K_SECTION_COUNT, + K_FOOTNOTE = K_SECTION_COUNT, } markdownKind; static kindDefinition MarkdownKinds[] = { @@ -50,6 +54,7 @@ static kindDefinition MarkdownKinds[] = { { true, 't', "subsubsection", "level 3 sections" }, { true, 'T', "l4subsection", "level 4 sections" }, { true, 'u', "l5subsection", "level 5 sections" }, + { true, 'n', "footnote", "footnotes" }, }; static fieldDefinition MarkdownFields [] = { @@ -183,6 +188,27 @@ static void fillEndField (NestingLevel *nl, void *ctxData) } } +static void getFootnoteMaybe (const char *line) +{ + const char *start = strstr (line, "[^"); + const char *end = start? strstr(start + 2, "]:"): NULL; + + if (! (start && end)) + return; + if (! (end > (start + 2))) + return; + + vString * footnote = vStringNewNInit (start + 2, end - (start + 2)); + const NestingLevel *const nl = nestingLevelsGetCurrent (nestingLevels); + tagEntryInfo e; + + initTagEntry (&e, vStringValue (footnote), K_FOOTNOTE); + if (nl) + e.extensionFields.scopeIndex = nl->corkIndex; + makeTagEntry (&e); + + vStringDelete (footnote); +} static void findMarkdownTags (void) { @@ -315,7 +341,10 @@ static void findMarkdownTags (void) vStringClear (prevLine); if (!lineProcessed) + { + getFootnoteMaybe ((const char *)line); vStringCatS (prevLine, (const char*) line); + } } vStringDelete (prevLine); vStringDelete (codeLang); From 8d4de3bd41c91e015839406e104505b0e6e24b86 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 15 Mar 2022 07:13:53 +0900 Subject: [PATCH 3/6] Markdown: adjust areas of codeblocks This is a fix for potential bugs. Signed-off-by: Masatake YAMATO --- parsers/markdown.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/parsers/markdown.c b/parsers/markdown.c index db02b462fc..704e235339 100644 --- a/parsers/markdown.c +++ b/parsers/markdown.c @@ -229,7 +229,7 @@ static void findMarkdownTags (void) bool lineProcessed = false; bool indented; int pos = getFirstCharPos (line, lineLen, &indented); - int lineNum = getInputLineNumber (); + const int lineNum = getInputLineNumber (); if (lineNum == 1 || inPreambule) { @@ -255,16 +255,16 @@ static void findMarkdownTags (void) inCodeChar = 0; else if (inCodeChar) { - startSourceLineNumber = getSourceLineNumber (); - startLineNumber = getInputLineNumber (); + startLineNumber = startSourceLineNumber = lineNum + 1; vStringCopyS (codeLang, (const char *)(line + pos + nSame)); vStringStripLeading (codeLang); vStringStripTrailing (codeLang); } else { - long endLineNumber = getInputLineNumber () - 1; - if (vStringLength (codeLang) > 0) + long endLineNumber = lineNum; + if (vStringLength (codeLang) > 0 + && startLineNumber < endLineNumber) makePromise (vStringValue (codeLang), startLineNumber, 0, endLineNumber, 0, startSourceLineNumber); } From 3bbeaff45d748874f566350ab065b5510e382c16 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 15 Mar 2022 08:35:17 +0900 Subject: [PATCH 4/6] RMarkdown: new parser The parser supports "{r label}" syntax as described in https://bookdown.org/yihui/rmarkdown/. "{r" part is parsed to choose a guest. "label" in "label}" part is tagged as a chunkLabel kind object. Signed-off-by: Masatake YAMATO --- .../list-subparsers-all.d/stdout-expected.txt | 1 + .../simple-rmarkdown.d/args.ctags | 3 + .../simple-rmarkdown.d/expected.tags | 11 ++ .../simple-rmarkdown.d/input.rmd | 27 ++++ docs/news.rst | 1 + main/parsers_p.h | 1 + parsers/markdown.c | 38 ++++- parsers/markdown.h | 29 ++++ parsers/rmarkdown.c | 134 ++++++++++++++++++ source.mak | 2 + win32/ctags_vs2013.vcxproj | 2 + win32/ctags_vs2013.vcxproj.filters | 6 + 12 files changed, 252 insertions(+), 3 deletions(-) create mode 100644 Units/parser-rmarkdown.r/simple-rmarkdown.d/args.ctags create mode 100644 Units/parser-rmarkdown.r/simple-rmarkdown.d/expected.tags create mode 100644 Units/parser-rmarkdown.r/simple-rmarkdown.d/input.rmd create mode 100644 parsers/markdown.h create mode 100644 parsers/rmarkdown.c diff --git a/Tmain/list-subparsers-all.d/stdout-expected.txt b/Tmain/list-subparsers-all.d/stdout-expected.txt index e7828c39d1..52b9d69597 100644 --- a/Tmain/list-subparsers-all.d/stdout-expected.txt +++ b/Tmain/list-subparsers-all.d/stdout-expected.txt @@ -15,6 +15,7 @@ PlistXML XML base <> sub {bidirectional} PythonLoggingConfig Iniconf base <> sub {bidirectional} QtMoc C++ base <> sub {bidirectional} R6Class R base <> sub {bidirectional} +RMarkdown Markdown base <= sub {dedicated} RSpec Ruby base => sub {shared} RelaxNG XML base <> sub {bidirectional} S4Class R base <> sub {bidirectional} diff --git a/Units/parser-rmarkdown.r/simple-rmarkdown.d/args.ctags b/Units/parser-rmarkdown.r/simple-rmarkdown.d/args.ctags new file mode 100644 index 0000000000..0067e01973 --- /dev/null +++ b/Units/parser-rmarkdown.r/simple-rmarkdown.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+g +--fields=+KenlE diff --git a/Units/parser-rmarkdown.r/simple-rmarkdown.d/expected.tags b/Units/parser-rmarkdown.r/simple-rmarkdown.d/expected.tags new file mode 100644 index 0000000000..50d750120d --- /dev/null +++ b/Units/parser-rmarkdown.r/simple-rmarkdown.d/expected.tags @@ -0,0 +1,11 @@ +S1 input.rmd /^# S1$/;" chapter line:1 language:Markdown end:14 +xyX input.rmd /^```{r xyX}$/;" chunklabel line:3 language:RMarkdown extras:subparser +S2 input.rmd /^# S2$/;" chapter line:15 language:Markdown end:25 +__anon4a45a9700100 input.rmd /^```{r, cache = TRUE, dependson = "xyX"}$/;" chunklabel line:17 language:RMarkdown extras:subparser,anonymous +__anon4a45a9700200 input.rmd /^```{python}$/;" chunklabel line:21 language:RMarkdown extras:subparser,anonymous +S3 input.rmd /^# S3$/;" chapter line:26 language:Markdown end:27 +x input.rmd /^x <- 1$/;" globalVar line:5 language:R extras:guest end:5 +foo input.rmd /^foo <- function () {$/;" function line:6 language:R extras:guest end:9 +y input.rmd /^ y <- 2$/;" functionVar line:7 language:R function:foo extras:guest end:7 +X input.rmd /^X <- func()$/;" globalVar line:11 language:R extras:guest end:11 +f input.rmd /^def f():$/;" function line:22 language:Python extras:guest end:24 diff --git a/Units/parser-rmarkdown.r/simple-rmarkdown.d/input.rmd b/Units/parser-rmarkdown.r/simple-rmarkdown.d/input.rmd new file mode 100644 index 0000000000..b0cd0d025a --- /dev/null +++ b/Units/parser-rmarkdown.r/simple-rmarkdown.d/input.rmd @@ -0,0 +1,27 @@ +# S1 + +```{r xyX} + +x <- 1 +foo <- function () { + y <- 2 + return(y) +} + +X <- func() + +``` + +# S2 + +```{r, cache = TRUE, dependson = "xyX"} +mean(X) +``` + +```{python} +def f(): + g() + return 3 +``` +# S3 + diff --git a/docs/news.rst b/docs/news.rst index 197b5e14be..3703ebaeec 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -455,6 +455,7 @@ The following parsers have been added: * R6Class *R based subparser* * RelaxNG *libxml* * ReStructuredText +* RMarkdown *Markdown based subparser* * Robot * RpmMacros *optlib* * RpmSpec diff --git a/main/parsers_p.h b/main/parsers_p.h index aae97fd4ce..e6f25891a1 100644 --- a/main/parsers_p.h +++ b/main/parsers_p.h @@ -137,6 +137,7 @@ PythonLoggingConfigParser, \ QemuHXParser, \ QtMocParser, \ + RMarkdownParser, \ RParser, \ R6ClassParser, \ RSpecParser, \ diff --git a/parsers/markdown.c b/parsers/markdown.c index 704e235339..b528accb26 100644 --- a/parsers/markdown.c +++ b/parsers/markdown.c @@ -33,6 +33,8 @@ #include "promise.h" #include "htable.h" +#include "markdown.h" + /* * DATA DEFINITIONS */ @@ -210,6 +212,26 @@ static void getFootnoteMaybe (const char *line) vStringDelete (footnote); } +static bool extractLanguageForCodeBlock (const char *langMarker, + vString *codeLang) +{ + subparser *s; + bool r = false; + + foreachSubparser (s, false) + { + markdownSubparser *m = (markdownSubparser *)s; + enterSubparser(s); + if (m->extractLanguageForCodeBlock) + r = m->extractLanguageForCodeBlock (m, langMarker, codeLang); + leaveSubparser(); + if (r) + break; + } + + return r; +} + static void findMarkdownTags (void) { vString *prevLine = vStringNew (); @@ -221,6 +243,10 @@ static void findMarkdownTags (void) bool inPreambule = false; bool inComment = false; + subparser *sub = getSubparserRunningBaseparser(); + if (sub) + chooseExclusiveSubparser (sub, NULL); + nestingLevels = nestingLevelsNewFull (0, fillEndField); while ((line = readLineFromInputFile ()) != NULL) @@ -255,10 +281,16 @@ static void findMarkdownTags (void) inCodeChar = 0; else if (inCodeChar) { + const char *langMarker = (const char *)(line + pos + nSame); startLineNumber = startSourceLineNumber = lineNum + 1; - vStringCopyS (codeLang, (const char *)(line + pos + nSame)); - vStringStripLeading (codeLang); - vStringStripTrailing (codeLang); + + vStringClear (codeLang); + if (! extractLanguageForCodeBlock (langMarker, codeLang)) + { + vStringCopyS (codeLang, langMarker); + vStringStripLeading (codeLang); + vStringStripTrailing (codeLang); + } } else { diff --git a/parsers/markdown.h b/parsers/markdown.h new file mode 100644 index 0000000000..2af2372aca --- /dev/null +++ b/parsers/markdown.h @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2022, Masatake YAMATO +* +* This source code is released for free distribution under the terms of the +* GNU General Public License version 2 or (at your option) any later version. +* +* The interface for subparsers of Markdown +*/ +#ifndef CTAGS_PARSER_MARKDOWN_H +#define CTAGS_PARSER_MARKDOWN_H + +/* +* INCLUDE FILES +*/ +#include "general.h" /* must always come first */ + +#include "subparser.h" +#include "vstring.h" + +typedef struct sMarkdownSubparser markdownSubparser; + +struct sMarkdownSubparser { + subparser subparser; + bool (* extractLanguageForCodeBlock) (markdownSubparser *s, + const char *langMarker, + vString *langName); +}; + +#endif diff --git a/parsers/rmarkdown.c b/parsers/rmarkdown.c new file mode 100644 index 0000000000..e7a453dbf7 --- /dev/null +++ b/parsers/rmarkdown.c @@ -0,0 +1,134 @@ +/* + * + * Copyright (c) 2022, Masatake YAMATO + * + * This source code is released for free distribution under the terms of the + * GNU General Public License version 2 or (at your option) any later version. + * + * This module contains functions for generating tags for R Markdown files. + * https://bookdown.org/yihui/rmarkdown/ + * + */ + +/* + * INCLUDE FILES + */ +#include "general.h" /* must always come first */ +#include "markdown.h" + +#include "entry.h" +#include "parse.h" + +#include +#include + +/* + * DATA DEFINITIONS + */ +typedef enum { + K_CHUNK_LABEL = 0, +} rmarkdownKind; + +static kindDefinition RMarkdownKinds[] = { + { true, 'l', "chunklabel", "chunk labels"}, +}; + +struct sRMarkdownSubparser { + markdownSubparser markdown; +}; + +/* +* FUNCTION DEFINITIONS +*/ + +static void findRMarkdownTags (void) +{ + scheduleRunningBaseparser (0); +} + +#define skip_space(CP) while (*CP == ' ' || *CP == '\t') CP++; + +static void makeRMarkdownTag (vString *name, int kindIndex, bool anonymous) +{ + tagEntryInfo e; + initTagEntry (&e, vStringValue (name), kindIndex); + if (anonymous) + markTagExtraBit (&e, XTAG_ANONYMOUS); + makeTagEntry (&e); +} + +static bool extractLanguageForCodeBlock (markdownSubparser *s, + const char *langMarker, + vString *langName) +{ + const char *cp = langMarker; + + if (*cp != '{') + return false; + cp++; + + const char *end = strpbrk(cp, " \t,}"); + if (!end) + return false; + + if (end - cp == 0) + return false; + + vStringNCatS (langName, cp, end - cp); + + cp = end; + if (*cp == ',' || *cp == '}') + { + vString *name = anonGenerateNew("__anon", K_CHUNK_LABEL); + makeRMarkdownTag (name, K_CHUNK_LABEL, true); + vStringDelete (name); + return true; + } + + skip_space(cp); + + vString *chunk_label = vStringNew (); + bool anonymous = false; + while (isalnum((unsigned char)*cp) || *cp == '-') + vStringPut (chunk_label, *cp++); + + if (vStringLength (chunk_label) == 0) + { + anonGenerate (chunk_label, "__anon", K_CHUNK_LABEL); + anonymous = true; + } + + skip_space(cp); + if (*cp == ',' || *cp == '}') + makeRMarkdownTag (chunk_label, K_CHUNK_LABEL, anonymous); + + vStringDelete (chunk_label); + return true; +} + +extern parserDefinition* RMarkdownParser (void) +{ + static const char *const extensions [] = { "rmd", NULL }; + static struct sRMarkdownSubparser rmarkdownSubparser = { + .markdown = { + .subparser = { + .direction = SUBPARSER_SUB_RUNS_BASE, + }, + .extractLanguageForCodeBlock = extractLanguageForCodeBlock, + }, + }; + static parserDependency dependencies [] = { + [0] = { DEPTYPE_SUBPARSER, "Markdown", &rmarkdownSubparser }, + }; + + parserDefinition* const def = parserNew ("RMarkdown"); + + + def->dependencies = dependencies; + def->dependencyCount = ARRAY_SIZE(dependencies); + def->kindTable = RMarkdownKinds; + def->kindCount = ARRAY_SIZE (RMarkdownKinds); + def->extensions = extensions; + def->parser = findRMarkdownTags; + return def; +} diff --git a/source.mak b/source.mak index 202bfced11..18b7459290 100644 --- a/source.mak +++ b/source.mak @@ -261,6 +261,7 @@ PARSER_HEADS = \ parsers/iniconf.h \ parsers/m4.h \ parsers/make.h \ + parsers/markdown.h \ parsers/perl.h \ parsers/r.h \ parsers/ruby.h \ @@ -356,6 +357,7 @@ PARSER_SRCS = \ parsers/r-s4class.c \ parsers/r.c \ parsers/rexx.c \ + parsers/rmarkdown.c \ parsers/robot.c \ parsers/rpmspec.c \ parsers/rspec.c \ diff --git a/win32/ctags_vs2013.vcxproj b/win32/ctags_vs2013.vcxproj index 609367b597..5bfb6e84b8 100644 --- a/win32/ctags_vs2013.vcxproj +++ b/win32/ctags_vs2013.vcxproj @@ -337,6 +337,7 @@ + @@ -448,6 +449,7 @@ + diff --git a/win32/ctags_vs2013.vcxproj.filters b/win32/ctags_vs2013.vcxproj.filters index 987b4e77b9..33ffcb3f2e 100644 --- a/win32/ctags_vs2013.vcxproj.filters +++ b/win32/ctags_vs2013.vcxproj.filters @@ -534,6 +534,9 @@ Source Files\parsers + + Source Files\parsers + Source Files\parsers @@ -863,6 +866,9 @@ Header Files + + Header Files + Header Files From 405e795f26711a831066f39a5c63539e3555be6f Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 15 Mar 2022 15:29:32 +0900 Subject: [PATCH 5/6] docs(man): add a page for RMarkdown Signed-off-by: Masatake YAMATO --- docs/man/ctags-lang-rmarkdown.7.rst | 98 +++++++++++++++++++++++++++++ man/Makefile.am | 1 + man/ctags-lang-rmarkdown.7.rst.in | 98 +++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+) create mode 100644 docs/man/ctags-lang-rmarkdown.7.rst create mode 100644 man/ctags-lang-rmarkdown.7.rst.in diff --git a/docs/man/ctags-lang-rmarkdown.7.rst b/docs/man/ctags-lang-rmarkdown.7.rst new file mode 100644 index 0000000000..65620ed248 --- /dev/null +++ b/docs/man/ctags-lang-rmarkdown.7.rst @@ -0,0 +1,98 @@ +.. _ctags_lang-rmarkdown(7): + +====================================================================== +ctags-lang-rmarkdown +====================================================================== + +Random notes about tagging R Markdown source code with Universal Ctags + +:Version: 5.9.0 +:Manual group: Universal Ctags +:Manual section: 7 + +SYNOPSIS +-------- +| **ctags** ...--extras=+{subparser}{guest} --languages=+RMarkdown ... +| **ctags** ...--extras=+{subparser}{guest} --language-force=RMarkdown ... +| **ctags** ...--extras=+{subparser}{guest} --map-RMarkdown=+.rmd ... + +DESCRIPTION +----------- +RMarkdown parser is an exclusive subparser stacked on top of the Markdown parser. +It works when: + +* the Markdown parser is enabled, +* the ``subparser`` extra is enabled, and +* the RMarkdown parser itself is enabled. + +The RMarkdown parser extends the way of detecting **codeblocks** from the +Markdown parser for running guest parsers on **code chunks**. + +The Markdown parser expects the following syntax for codeblocks + +.. code-block:: + + ```language-name + ... + ``` + +For an example + +.. code-block:: + + ```r + ... + ``` + +The RMarkdown parser accepts the following syntax for code chunks +as the markdown parser accepts codeblocks + +.. code-block:: + + ```{language-name chunk-label, ...} + ... + ``` + +For an example + +.. code-block:: + + ```{r precalc fig.height=4} + ... + ``` + +Give `--extras=+{guest}` for enabling ``guest`` to command line if you +want to run proper parsers on inside code chunks. + +The parser extrats chunk labels coming after `language-name` as +`chunklabel` kind objcts. The kind is enabled by default. + +EXAMPLES +-------- +"input.rmd" + +.. code-block:: RMarkdown + + # Section 1 + + ```{r myblock} + zero_fun <- function () { + return 0 + } + ``` + + # Section 2 + +"output.tags" +with "--options=NONE --extras=+{guest} --fields=+KZln -o - input.rmd" + +.. code-block:: tags + + Section 1 input.rmd /^# Section 1$/;" chapter line:1 language:Markdown + Section 2 input.rmd /^# Section 2$/;" chapter line:9 language:Markdown + myblock input.rmd /^```{r myblock}$/;" chunklabel line:3 language:RMarkdown + zero_fun input.rmd /^ zero_fun <- function () {$/;" function line:4 language:R + +SEE ALSO +-------- +:ref:`ctags(1) `, :ref:`ctags-client-tools(7) `, `R Markdown: The Definitive Guide `_ diff --git a/man/Makefile.am b/man/Makefile.am index f7e8481201..7746be1765 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -35,6 +35,7 @@ GEN_IN_MAN_FILES = \ ctags-lang-verilog.7 \ ctags-lang-inko.7 \ ctags-lang-r.7 \ + ctags-lang-rmarkdown.7 \ ctags-lang-sql.7 \ \ readtags.1 \ diff --git a/man/ctags-lang-rmarkdown.7.rst.in b/man/ctags-lang-rmarkdown.7.rst.in new file mode 100644 index 0000000000..c3bef24b15 --- /dev/null +++ b/man/ctags-lang-rmarkdown.7.rst.in @@ -0,0 +1,98 @@ +.. _ctags_lang-rmarkdown(7): + +====================================================================== +ctags-lang-rmarkdown +====================================================================== +----------------------------------------------------------------------- +Random notes about tagging R Markdown source code with Universal Ctags +----------------------------------------------------------------------- +:Version: @VERSION@ +:Manual group: Universal Ctags +:Manual section: 7 + +SYNOPSIS +-------- +| **@CTAGS_NAME_EXECUTABLE@** ...--extras=+{subparser}{guest} --languages=+RMarkdown ... +| **@CTAGS_NAME_EXECUTABLE@** ...--extras=+{subparser}{guest} --language-force=RMarkdown ... +| **@CTAGS_NAME_EXECUTABLE@** ...--extras=+{subparser}{guest} --map-RMarkdown=+.rmd ... + +DESCRIPTION +----------- +RMarkdown parser is an exclusive subparser stacked on top of the Markdown parser. +It works when: + +* the Markdown parser is enabled, +* the ``subparser`` extra is enabled, and +* the RMarkdown parser itself is enabled. + +The RMarkdown parser extends the way of detecting **codeblocks** from the +Markdown parser for running guest parsers on **code chunks**. + +The Markdown parser expects the following syntax for codeblocks + +.. code-block:: + + ```language-name + ... + ``` + +For an example + +.. code-block:: + + ```r + ... + ``` + +The RMarkdown parser accepts the following syntax for code chunks +as the markdown parser accepts codeblocks + +.. code-block:: + + ```{language-name chunk-label, ...} + ... + ``` + +For an example + +.. code-block:: + + ```{r precalc fig.height=4} + ... + ``` + +Give `--extras=+{guest}` for enabling ``guest`` to command line if you +want to run proper parsers on inside code chunks. + +The parser extrats chunk labels coming after `language-name` as +`chunklabel` kind objcts. The kind is enabled by default. + +EXAMPLES +-------- +"input.rmd" + +.. code-block:: RMarkdown + + # Section 1 + + ```{r myblock} + zero_fun <- function () { + return 0 + } + ``` + + # Section 2 + +"output.tags" +with "--options=NONE --extras=+{guest} --fields=+KZln -o - input.rmd" + +.. code-block:: tags + + Section 1 input.rmd /^# Section 1$/;" chapter line:1 language:Markdown + Section 2 input.rmd /^# Section 2$/;" chapter line:9 language:Markdown + myblock input.rmd /^```{r myblock}$/;" chunklabel line:3 language:RMarkdown + zero_fun input.rmd /^ zero_fun <- function () {$/;" function line:4 language:R + +SEE ALSO +-------- +ctags(1), ctags-client-tools(7), `R Markdown: The Definitive Guide `_ From e59379f6b8637683f232ef9c0f062fc4c671a87b Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 15 Mar 2022 15:30:35 +0900 Subject: [PATCH 6/6] docs(man): minor fix for iPythonCell Signed-off-by: Masatake YAMATO --- docs/man/ctags-lang-iPythonCell.7.rst | 8 ++++---- man/ctags-lang-iPythonCell.7.rst.in | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/man/ctags-lang-iPythonCell.7.rst b/docs/man/ctags-lang-iPythonCell.7.rst index de035a43f7..9688fac863 100644 --- a/docs/man/ctags-lang-iPythonCell.7.rst +++ b/docs/man/ctags-lang-iPythonCell.7.rst @@ -12,20 +12,20 @@ The man page of the iPythonCell parser for Universal Ctags SYNOPSIS -------- -| **ctags** ... --extras={subparser} --languages=+iPythonCell,Python \\ +| **ctags** ... --extras=+{subparser} --languages=+iPythonCell,Python \\ | [--extras-IPythonCell=+{doubleSharps}] \\ | [--regex-IPythonCell=//\\n/c/] ... DESCRIPTION ----------- -iPythonCell is a subparser stacked on top of the Python parser. +iPythonCell parser is a subparser stacked on top of the Python parser. It works when: -* The Python parser is enabled, +* the Python parser is enabled, * the ``subparser`` extra is enabled, and * the iPythonCell parser itself is enabled. -iPythonCell extracts cells explained as in vim-ipython-cell +The iPythonCell parser extracts cells explained as in vim-ipython-cell (https://github.com/hanschen/vim-ipython-cell/blob/master/README.md). KIND(S) diff --git a/man/ctags-lang-iPythonCell.7.rst.in b/man/ctags-lang-iPythonCell.7.rst.in index 6d3e9a8f05..25ba1bd73e 100644 --- a/man/ctags-lang-iPythonCell.7.rst.in +++ b/man/ctags-lang-iPythonCell.7.rst.in @@ -12,20 +12,20 @@ The man page of the iPythonCell parser for Universal Ctags SYNOPSIS -------- -| **@CTAGS_NAME_EXECUTABLE@** ... --extras={subparser} --languages=+iPythonCell,Python \\ +| **@CTAGS_NAME_EXECUTABLE@** ... --extras=+{subparser} --languages=+iPythonCell,Python \\ | [--extras-IPythonCell=+{doubleSharps}] \\ | [--regex-IPythonCell=//\\n/c/] ... DESCRIPTION ----------- -iPythonCell is a subparser stacked on top of the Python parser. +iPythonCell parser is a subparser stacked on top of the Python parser. It works when: -* The Python parser is enabled, +* the Python parser is enabled, * the ``subparser`` extra is enabled, and * the iPythonCell parser itself is enabled. -iPythonCell extracts cells explained as in vim-ipython-cell +The iPythonCell parser extracts cells explained as in vim-ipython-cell (https://github.com/hanschen/vim-ipython-cell/blob/master/README.md). KIND(S)