You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2018/02/11 19:42:08 UTC

[whimsy] branch master updated: add ordered list and incubator punction rules to reflow logic

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 449871e  add ordered list and incubator punction rules to reflow logic
449871e is described below

commit 449871e89f60397572db24634efd6350155d529e
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sun Feb 11 14:41:47 2018 -0500

    add ordered list and incubator punction rules to reflow logic
---
 www/board/agenda/views/buttons/post.js.rb |  7 +++++--
 www/board/agenda/views/utils.js.rb        | 14 +++++++++-----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/www/board/agenda/views/buttons/post.js.rb b/www/board/agenda/views/buttons/post.js.rb
index 0689514..0218f30 100644
--- a/www/board/agenda/views/buttons/post.js.rb
+++ b/www/board/agenda/views/buttons/post.js.rb
@@ -211,13 +211,16 @@ class Post < Vue
       end
     end
 
+    # enable special punctuation rules for the incubator
+    puncrules = (@@item.title == 'Incubator')
+
     # reflow selection or entire report
     if finish > start
-      report = Flow.text(report[start..finish], @indent+indent)
+      report = Flow.text(report[start..finish], @indent+indent, puncrules)
       report.gsub(/^/, ' ' * indent) if indent > 0
       @report = @report[0...start] + report + @report[finish+1..-1]
     else
-      @report = Flow.text(report, @indent)
+      @report = Flow.text(report, @indent, puncrules)
     end
 
     self.change_message()
diff --git a/www/board/agenda/views/utils.js.rb b/www/board/agenda/views/utils.js.rb
index 1f67d98..4085c20 100644
--- a/www/board/agenda/views/utils.js.rb
+++ b/www/board/agenda/views/utils.js.rb
@@ -146,8 +146,11 @@ class Flow
     return lines.join("\n")
   end
 
-  # reflow text
-  def self.text(text, indent='')
+  # reflow text.  Indent is a string containing the amount of spaces that are
+  # to be added to each line.  The Incubator has special punctuation rules that
+  # prohibit the joining of lines where the first line ends in either a colon
+  # or a question mark.
+  def self.text(text, indent='', puncrules=false)
     # remove trailing spaces on lines
     text.gsub! /[ \r\t]+\n/, "\n"
 
@@ -158,7 +161,8 @@ class Flow
     # hash (#) and <markers> like <private>, ")".
     (lines.length-1).downto(1) do |i|
       next if lines[i-1] =~ /^$|^#|\w>$/
-      if lines[i] =~ /^\s*\w/
+      next if puncrules and lines[i-1] =~ /[:?]$/
+      if lines[i] =~ /^\s*\w/ and lines[i] !~ /^\s*\d+\./
         lines.splice(i-1, 2, lines[i-1] + lines[i].sub(/^\s*/, ' '))
       end
     end
@@ -168,7 +172,7 @@ class Flow
     for i in 0...lines.length
       line = lines[i]
       next if line.length <= len
-      prefix = /^\W*/.exec(line)[0]
+      prefix = /^\d+\.\s+|^\W*/.exec(line)[0]
 
       if prefix.length == 0
         # not indented -> split
@@ -178,7 +182,7 @@ class Flow
       else
         # preserve indentation.
         n = len - prefix.length;
-        indent = prefix.gsub(/\W/, ' ')
+        indent = prefix.gsub(/\S/, ' ')
         lines[i] = prefix + line[prefix.length..-1].
           gsub(/(.{1,#{n}})( +|$\n?)/, indent + "$1\n").
           sub(indent, '').sub(/[\n\r]+$/, '')

-- 
To stop receiving notification emails like this one, please contact
rubys@apache.org.