Grammalecte  Check-in [ec919db910]

Overview
Comment:[core][js][py] text.getParagraph(): end of line handling
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core | webext2
Files: files | file ages | folders
SHA3-256: ec919db910994d91f4e04cb697593570f8d7d2cd78c2ddc59e54b0e24dc79cfc
User & Date: olr on 2017-08-15 08:12:57
Other Links: branch diff | manifest | tags
Context
2017-08-15
08:36
[fx] lexicographer: count paragraphs analyzed check-in: eef32ad83f user: olr tags: fx, webext2
08:12
[core][js][py] text.getParagraph(): end of line handling check-in: ec919db910 user: olr tags: core, webext2
08:03
[fx] lexicographer: test list of tokens before creating node check-in: 44bd5f582f user: olr tags: fx, webext2
Changes

Modified gc_core/js/text.js from [2f8045c94f] to [9bf91b3594].

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25


var text = {
    getParagraph: function* (sText) {
        // generator: returns paragraphs of text
        let iStart = 0;
        let iEnd = 0;
        sText = sText.replace("\r", "");
        while ((iEnd = sText.indexOf("\n", iStart)) !== -1) {
            yield sText.slice(iStart, iEnd);
            iStart = iEnd + 1;
        }
        yield sText.slice(iStart);
    },








|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25


var text = {
    getParagraph: function* (sText) {
        // generator: returns paragraphs of text
        let iStart = 0;
        let iEnd = 0;
        sText = sText.replace("\r\n", "\n").replace("\r", "\n");
        while ((iEnd = sText.indexOf("\n", iStart)) !== -1) {
            yield sText.slice(iStart, iEnd);
            iStart = iEnd + 1;
        }
        yield sText.slice(iStart);
    },

Modified gc_core/py/text.py from [e964ece40d] to [72d4931466].

1
2
3
4
5
6
7
8
9

10
11
12
13
14
15
16
#!python3

import textwrap
from itertools import chain


def getParagraph (sText):
    "generator: returns paragraphs of text"
    iStart = 0

    iEnd = sText.find("\n", iStart)
    while iEnd != -1:
        yield sText[iStart:iEnd]
        iStart = iEnd + 1
        iEnd = sText.find("\n", iStart)
    yield sText[iStart:]










>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!python3

import textwrap
from itertools import chain


def getParagraph (sText):
    "generator: returns paragraphs of text"
    iStart = 0
    sText = sText.replace("\r\n", "\n").replace("\r", "\n")
    iEnd = sText.find("\n", iStart)
    while iEnd != -1:
        yield sText[iStart:iEnd]
        iStart = iEnd + 1
        iEnd = sText.find("\n", iStart)
    yield sText[iStart:]