From 422cdce39583b3dbdebb5b7b52b922a598d24ca1 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Tue, 1 Aug 2023 02:46:40 +0900 Subject: [PATCH] ReStructuredText: skip prefixed whitespaces when parsing markup lines Signed-off-by: Masatake YAMATO --- .../markup-line-with-spaces.d/args.ctags | 1 + .../markup-line-with-spaces.d/expected.tags | 4 ++++ .../markup-line-with-spaces.d/input.rst | 11 +++++++++++ parsers/rst.c | 11 ++++++++--- 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 Units/parser-restructuredtext.r/markup-line-with-spaces.d/args.ctags create mode 100644 Units/parser-restructuredtext.r/markup-line-with-spaces.d/expected.tags create mode 100644 Units/parser-restructuredtext.r/markup-line-with-spaces.d/input.rst diff --git a/Units/parser-restructuredtext.r/markup-line-with-spaces.d/args.ctags b/Units/parser-restructuredtext.r/markup-line-with-spaces.d/args.ctags new file mode 100644 index 0000000000..5ee5f79f70 --- /dev/null +++ b/Units/parser-restructuredtext.r/markup-line-with-spaces.d/args.ctags @@ -0,0 +1 @@ +--sort=no diff --git a/Units/parser-restructuredtext.r/markup-line-with-spaces.d/expected.tags b/Units/parser-restructuredtext.r/markup-line-with-spaces.d/expected.tags new file mode 100644 index 0000000000..0245e36f23 --- /dev/null +++ b/Units/parser-restructuredtext.r/markup-line-with-spaces.d/expected.tags @@ -0,0 +1,4 @@ +OVERVIEW input.rst /^ .. [OVERVIEW] `Satellite Overview, Concepts, and Deployment Considerations `_ + +* Administering Red Hat Satellite + + .. [ADMIN] `Administering Red Hat Satellite `_ + + .. [LOC] `Chapter 6. Managing Locations `_ + + .. [USERROLE] `Chapter 7. Managing Users and Roles `_ diff --git a/parsers/rst.c b/parsers/rst.c index 43cb7beb1c..dc632f97ea 100644 --- a/parsers/rst.c +++ b/parsers/rst.c @@ -219,9 +219,14 @@ static int get_kind(char c, bool overline, struct sectionTracker tracker[]) static const unsigned char *is_markup_line (const unsigned char *line, char reftype) { - if ((line [0] == '.') && (line [1] == '.') && (line [2] == ' ') - && (line [3] == reftype)) - return line + 4; + unsigned int i = 0; + + while (isspace(line[i])) + i++; + + if ((line [i+0] == '.') && (line [i+1] == '.') && (line [i+2] == ' ') + && (line [i+3] == reftype)) + return line + i + 4; return NULL; }