Comments in the registry added to the HTML output. Closes #2

This commit is contained in:
Stephane Bortzmeyer 2023-09-06 18:25:16 +02:00
parent e9d873ffe7
commit b6101769a2
3 changed files with 26 additions and 14 deletions

View File

@ -67,6 +67,7 @@ recordFactory r =
(lookup "Macrolanguage" r)
(lookup "Deprecated" r)
(lookup "Scope" r)
(lookup "Comments" r)
))
"extlang" -> Right (Extl (Extlang
(fromJust (lookup "Subtag" r))
@ -81,16 +82,19 @@ recordFactory r =
"script" -> Right (Scr (Script
(fromJust (lookup "Subtag" r))
(lookups "Description" r)
(fromJust (lookup "Added" r))))
(fromJust (lookup "Added" r))
(lookup "Comments" r)))
"region" -> Right (Reg (Region
(fromJust (lookup "Subtag" r))
(lookups "Description" r)
(fromJust (lookup "Added" r))))
(fromJust (lookup "Added" r))
(lookup "Comments" r)))
"variant" -> Right (Var (Variant
(fromJust (lookup "Subtag" r))
(lookups "Description" r)
(fromJust (lookup "Added" r))
(lookups "Prefix" r)))
(lookups "Prefix" r)
(lookup "Comments" r)))
"redundant" -> Right (Red (Redundant
(fromJust (lookup "Tag" r))
(lookups "Description" r)
@ -161,4 +165,4 @@ parse input =
let firstErr = (filter isLeft reg) !! 0 in
SyntaxError ("Registry is not legal: " ++
fromLeft firstErr)
-- TODO: the line number
-- TODO: the line number

View File

@ -3,14 +3,14 @@ module Registry.Types where
-- TODO: import Time and use CalendarTime
type DateTime = String
-- TODO for all: Comments
data Language = Language {lang'subtag::String, lang'descr::[String],
lang'added::DateTime, lang'script::Maybe String,
lang'preferredValue::Maybe String,
lang'macroLanguage::Maybe String,
lang'deprecated::Maybe DateTime,
lang'scope::Maybe String}
lang'scope::Maybe String,
lang'comment::Maybe String
}
deriving Show
data Extlang = Extlang {extlang'subtag::String, extlang'descr::[String],
@ -22,14 +22,15 @@ data Extlang = Extlang {extlang'subtag::String, extlang'descr::[String],
deriving Show
data Script = Script {script'subtag::String, script'descr::[String],
script'added::DateTime} deriving Show
script'added::DateTime, script'comment::Maybe String} deriving Show
data Region = Region {region'subtag::String, region'descr::[String],
region'added::DateTime} deriving Show
region'added::DateTime, region'comment::Maybe String} deriving Show
-- TODO: Deprecated and preferredValue
data Variant = Variant {variant'subtag::String, variant'descr::[String],
variant'added::DateTime, variant'prefix::[String]} deriving Show
variant'added::DateTime, variant'prefix::[String],
variant'comment::Maybe String} deriving Show
data Redundant = Redundant {redundant'tag::String, redundant'descr::[String],
redundant'added::DateTime} deriving Show

View File

@ -184,31 +184,38 @@ descrToHTML a = concat (List.intersperse " / " (map onedescrToHTML a))
-- TODO: a prefix is not always a simple language, it can be composed of several subtags
oneprefixToHTML s = " Possible prefix: <code><a href=\"../language/" ++ s ++ ".html\">" ++ s ++ "</a></code>"
prefixesToHTML a = concat (map oneprefixToHTML a)
commentToHTML Nothing = ""
commentToHTML (Just s) = " Comment: " ++ s
toHTML (Date d) = "<p>Date: " ++ dateToHTML d ++ "</p>"
toHTML (Lang l) = (html_head ((lang'descr l) !! 0)) ++ "<p>Code <code>" ++
(lang'subtag l) ++ "</code>. " ++
addedToHTML (lang'added l) ++ ". Description: " ++
descrToHTML (lang'descr l) ++ ". " ++
linkLanguage (lang'subtag l) ++
(sscriptToHTML (lang'script l)) ++ "</p>" ++ html_tail ++ "\n"
(sscriptToHTML (lang'script l)) ++
commentToHTML (lang'comment l) ++ "</p>" ++ html_tail ++ "\n"
toHTML (GF t) = "<p>Code <code>" ++ (gf'tag t) ++ "</code>. " ++
addedToHTML (gf'added t) ++ ". " ++
descrToHTML (gf'descr t) ++ "</p>\n"
toHTML (Scr s) = (html_head ((script'descr s) !! 0)) ++ "<p>Code <code>" ++
(script'subtag s) ++ "</code>. " ++
addedToHTML (script'added s) ++ ". Description: " ++
descrToHTML (script'descr s) ++ "</p>" ++ html_tail ++ "\n"
descrToHTML (script'descr s) ++
commentToHTML (script'comment s) ++ "</p>" ++ html_tail ++ "\n"
toHTML (Reg r) = (html_head ((region'descr r) !! 0)) ++ "<p>Code <code>" ++
(region'subtag r) ++ "</code>. " ++
addedToHTML (region'added r) ++
". Description: " ++
descrToHTML (region'descr r) ++ "</p>" ++
descrToHTML (region'descr r) ++
commentToHTML (region'comment r) ++ "</p>" ++
html_tail ++ "\n"
toHTML (Var v) = (html_head ((variant'descr v) !! 0)) ++ "<p>Code <code>" ++
(variant'subtag v) ++ "</code>. " ++
addedToHTML (variant'added v) ++ ". Description: " ++
descrToHTML (variant'descr v) ++ ". " ++
prefixesToHTML (variant'prefix v) ++ "</p>" ++ html_tail ++ "\n"
prefixesToHTML (variant'prefix v) ++
commentToHTML (variant'comment v) ++ "</p>" ++ html_tail ++ "\n"
toHTML (Red r) = (html_head ((redundant'descr r) !! 0)) ++
"<p>Code <code>" ++ (redundant'tag r) ++ "</code>. " ++
addedToHTML (redundant'added r) ++ ". " ++