organice icon indicating copy to clipboard operation
organice copied to clipboard

Improve parser to read lines with multiple inline markup statements

Open munen opened this issue 4 years ago • 1 comments

The parser chokes on lines containing multiple inline markup statements.

PR with failing test: https://github.com/200ok-ch/organice/pull/157

After space, =-=, =:=, and =|= you can tap on the completion – no need to type the tag, property, etc.

It looks like:

image

Another example:

A header like This /is/ a header with multiple /italic statements/ all of the text between the 2 words will display as italic, too.

Screenshot 2019-11-03 at 19 21 31

munen avatar Jan 02 '20 14:01 munen

I think it is not easy, to fix it in a good way. It might not be worth the work, if we hopefully get a new parser with the org-parser repo...

We already have PR #157 with failing tests for this issue.

I share my analysis (in German) on this.

Ich glaube das ist eine ganze Gruppe von Bugs, die auftreten, wenn 'inline-markup' zu greedy geparsed wird.

Beispiel, das scheitert:

describe('regex collisions of inline-markup and different links', () => {
  test('Parse /italic/ followed by URL with /', () => {
    const result = parseMarkupAndCookies('/italic/ word http://example.com/ text');
    expect(result.length).toEqual(4); // tatsächlich 2
  });
});

Das liegt daran, dass der regex .* zwischen den Delimitern von inline-markup greedy ist :/

Here is the part of the problematic regex as parse diagram:

https://imgur.com/a/DmeQsQu

Ich hab schon probiert [^\11]* statt .* zu verwenden, aber selbst wenn das ein syntaktisch richtiger regex wäre hätten wir dann das Problem nur in die andere Richtung verschoben.

Ein weiteres Problem neben dem greedy .* ist, dass Group 14 nach dem schließenden Delimiter optional ist (siehe Diagramm). Dadurch scheitert z.B. auch dieser Test:

  test('Parse =verb= followed by URL with = in query', () => {
    const result = parseMarkupAndCookies('=URL=: http://example.com/?a=b');
    expect(result.length).toEqual(3); // tatsächlich 2
  });

schoettl avatar Jan 03 '20 19:01 schoettl

Closed by the wonderful and amazing work of @lechten in #910 :tada: :raised_hands: :fireworks: :pray:

munen avatar Dec 03 '22 16:12 munen