NixLabConnectionconnecting
CommitsCommit
web/dreamstop.openfp.net · commit

Letter readings and number clauses

SmSmartypants, 2026-12-06 21:59a5f56833e5#53 · 21/21

parents: 4f51e0ea1e

Letter readings and number clauses

The renderer letters the readings of an ambiguous sentence A, B, C and
numbers each clause in a reading from 1, the numbers /rel1 and the like
refer to.

3 files changed

Diff

 dreamstop-openfp-net-web/ChangeLog.md     |  1 +
 dreamstop-openfp-net-web/src/Site/View.hs | 25 ++++++++++++++++++-------
 dreamstop.css                             |  2 ++
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/dreamstop-openfp-net-web/ChangeLog.md b/dreamstop-openfp-net-web/ChangeLog.md
index 72abed1..656a2ec 100644
--- a/dreamstop-openfp-net-web/ChangeLog.md
+++ b/dreamstop-openfp-net-web/ChangeLog.md
@@ -4,6 +4,7 @@
  
 - The menu of positions now comes first on the front page, and the clear ChangeLog entry now follows it.
 - Each position's tab now ends with a short plain note on what the position records, naming its codes.
+- Readings of an ambiguous sentence are now lettered A, B, C, and the clauses in each reading are numbered 1, 2, 3, the numbers that references such as `/rel1` use.
 - Every code on the front page is now shown in its position's colour, including codes inside notes. The build now fails if a code appears outside a coloured code.
  
 ## 0.3.1.0 — 2026-12-06
diff --git a/dreamstop-openfp-net-web/src/Site/View.hs b/dreamstop-openfp-net-web/src/Site/View.hs
index 82ebcfe..317f1f4 100644
--- a/dreamstop-openfp-net-web/src/Site/View.hs
+++ b/dreamstop-openfp-net-web/src/Site/View.hs
@@ -15,7 +15,6 @@ module Site.View
 import           Control.Monad      (unless, void, when)
 import           Data.Char          (isUpper)
 import           Data.Kind          (Type)
-import           Data.List          (groupBy)
 import           DesignKit.Brand    (fontDisplay, gradientText)
 import           DesignKit.Effects  (scrollProgressBar)
 import           Miso               (App, Component (subs), Effect, component,
@@ -27,7 +26,7 @@ import           Miso.Event.Types   (KeyCode (KeyCode))
 import           Miso.FFI           (focus)
 import           Miso.Html.Element  (a_, blockquote_, button_, code_, div_,
                                      footer_, h1_, h2_, h3_, h4_, header_, li_,
-                                     nav_, ol_, p_, section_, span_, ul_)
+                                     nav_, p_, section_, span_, ul_)
 import           Miso.Html.Event    (onClick, onKeyDown)
 import           Miso.Html.Property (aria_, href_, id_, role_, tabindex_, type_)
 import           Miso.Property      (classList)
@@ -258,7 +257,7 @@ view (MkModel selected) =
       [r] -> [p_ [classList ["annotation"]] (reading r)]
       rs ->
         [ p_ [classList ["annotation"]] ["Readings:"]
-        , ol_ [classList ["annotation"]] (map (li_ [] . reading) rs)
+        , ul_ [classList ["annotation", "lettered"]] (zipWith lettered ['A' ..] rs)
         ]
  
     notePart :: Segment -> View Model Action
@@ -266,6 +265,9 @@ view (MkModel selected) =
       Words w -> text w
       Code c -> codepoints c
  
+    lettered :: Char -> Reading -> View Model Action
+    lettered letter r = li_ [] (text ("Reading " <> toMisoString [letter] <> ": ") : reading r)
+ 
     reading :: Reading -> [View Model Action]
     reading r = [codepoints (readingCodes r), text (": " <> readingGloss r)]
  
@@ -279,12 +281,21 @@ panelId l = "panel-" <> layerName l
  
 -- | A reading's codes, each in its own class, which codepoints.css colours by
 -- the code's position, with brackets, separators and places in neutral grey.
+-- Each clause, opened by a bracket, is numbered from 1, the numbers that
+-- references such as @/rel1@ use.
 codepoints :: MisoString -> View model action
-codepoints s =
-  code_ [] (map token (groupBy sameCase (fromMisoString s :: String)))
+codepoints s = code_ [] (tokens (1 :: Int) (fromMisoString s))
   where
-    sameCase :: Char -> Char -> Bool
-    sameCase a b = isUpper a == isUpper b
+    tokens :: Int -> String -> [View model action]
+    tokens n = \case
+      [] -> []
+      '[' : rest -> span_ [classList ["clause-number"]] [text (toMisoString (show n))] : mark "[" : tokens (n + 1) rest
+      cs@(c : _)
+        | isUpper c -> let (w, rest) = span isUpper cs in token w : tokens n rest
+        | otherwise -> let (w, rest) = break (\x -> isUpper x || x == '[') cs in mark w : tokens n rest
+ 
+    mark :: String -> View model action
+    mark w = span_ [classList ["cp-mark"]] [text (toMisoString w)]
  
     token :: String -> View model action
     token w = span_ [classList [if length w == 3 && all isUpper w then "cp-" <> toMisoString w else "cp-mark"]] [text (toMisoString w)]
diff --git a/dreamstop.css b/dreamstop.css
index b363bb3..eb937ac 100644
--- a/dreamstop.css
+++ b/dreamstop.css
@@ -155,3 +155,5 @@ ul.readings p.decides { color: var(--text); font-size: .9rem; }
 html:not(.dk-js) .tabs { display: none; }
 html.dk-js .panel.inactive { display: none; }
 html.dk-js .panel-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; }
+code .clause-number { font-size: .7em; vertical-align: super; color: var(--muted, #52525b); margin-right: .1em; }
+ul.annotation.lettered { list-style: none; padding-left: 0; }