Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

[[ Bug 19543 ]] Dictionary improperly parses hard wrapped lines #6164

Merged
merged 3 commits into from Dec 7, 2017

Conversation

bwmilby
Copy link
Contributor

@bwmilby bwmilby commented Nov 23, 2017

When a paragraph ends with a colon and the last word falls on a new line then that word is parsed as a new element. Due to the way the regex is parsed, something inside parenthesis before the colon could also trigger this bug.

The proposed fix: Unless there is a preceding blank line, assume that this term is part of the existing content. If there is no content, then assume it is indeed a new element. An exception is if the element contains the content on the same line, in that case a new element can start on the next line. Some LCB documentation has "Description:" immediately following another multi-line element without a blank line (i.e. examples). Added a check that can be extended if other elements are found that need to be treated as an exception.

I ran a diff on the built_api.js from before my change and after. There are 584 lines of changes. Not all of them are evident in the dictionary viewer. (Only the first 128 lines are for ~32 actual changes, the rest were due to reordering of svgpath and svgspinner in the JSON.)

Some entries fixed by the change:

  • open printing
  • open printing to pdf
  • switch

… word is followed by colon

When a paragraph ends with a colon and the last word falls on a new line then that word is parsed as a new element.  Due to the way the regex is parsed, something inside parenthesis before the colon could also trigger this bug.

The proposed fix:  Unless there is a preceding blank line, assume that this term is part of the existing content.  If there is no content, then assume it is indeed a new element.  An exception is if the element contains the content on the same line, in that case a new element can start on the next line.  Some LCB documentation has "Description:" immediately following another multi-line element without a blank line (i.e. examples).  Added a check that can be extended if other elements are found that need to be treated as an exception.

I ran a diff on the built_api.js from before my change and after.  There are 584 lines of changes.  Not all of them are evident in the dictionary viewer.  (Only the first 128 lines are for ~32 actual changes, the rest were due to reordering of svgpath and svgspinner in the JSON.)

Some entries fixed by the change:
- open printing
- open printing to pdf
- switch
@livecodeali
Copy link
Member

This looks good. I have one suggestion, which is to replace

--Always recognize certain elements: Description,

and

",Description"

with a suitably named constant, eg kAlwaysRecognizedElements or something.

Also, is the empty string deliberately included in the items? I believe it can't be empty anyway because of the regex, but I just want to make sure.

@bwmilby
Copy link
Contributor Author

bwmilby commented Dec 7, 2017

Empty string would not get used due to the regex so it isn’t needed (was copying a form I saw elsewhere).
I’ll update to use a constant.

Use a constant for the list of elements that are always recognized as such.  Currently just one item.
@livecodeali
Copy link
Member

@livecode-vulcan review ok 349a29a

@livecode-vulcan
Copy link
Contributor

💙 review by @livecodeali ok 349a29a

livecode-vulcan added a commit that referenced this pull request Dec 7, 2017
[[ Bug 19543 ]] Dictionary improperly parses hard wrapped lines

When a paragraph ends with a colon and the last word falls on a new line then that word is parsed as a new element.  Due to the way the regex is parsed, something inside parenthesis before the colon could also trigger this bug.

The proposed fix:  Unless there is a preceding blank line, assume that this term is part of the existing content.  If there is no content, then assume it is indeed a new element.  An exception is if the element contains the content on the same line, in that case a new element can start on the next line.  Some LCB documentation has "Description:" immediately following another multi-line element without a blank line (i.e. examples).  Added a check that can be extended if other elements are found that need to be treated as an exception.

I ran a diff on the built_api.js from before my change and after.  There are 584 lines of changes.  Not all of them are evident in the dictionary viewer.  (Only the first 128 lines are for ~32 actual changes, the rest were due to reordering of svgpath and svgspinner in the JSON.)

Some entries fixed by the change:
- open printing
- open printing to pdf
- switch
@livecode-vulcan
Copy link
Contributor

😎 test success 349a29a

  • try-community-armv6-android-api8: success
  • try-community-armv6-android-api9: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos11.1: success
  • try-community-universal-ios-iphonesimulator11.1: success
  • try-community-universal-mac-macosx10.6: success
  • try-community-universal-mac-macosx10.9: success
  • try-community-x86-linux-debian7: success
  • try-community-x86-linux-debian8: success
  • try-community-x86_64-linux-debian7: success
  • try-community-x86_64-linux-debian8: success
  • try-community-x86-win32: success
  • try-community-x86_64-win32: success

@livecodepanos livecodepanos added this to the 8.2.0-dp-3 milestone Dec 7, 2017
@livecodepanos livecodepanos merged commit 17fcd19 into livecode:develop-8.2 Dec 7, 2017
@bwmilby bwmilby deleted the bwm-bugfix-19543 branch January 16, 2018 02:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants