Compare commits
4 Commits
f6d10672d2
...
1136cff702
Author | SHA1 | Date |
---|---|---|
Rhiannon Morris | 1136cff702 | |
Rhiannon Morris | abd27eebe9 | |
Rhiannon Morris | 7ad0415e38 | |
Rhiannon Morris | 9d23f99948 |
|
@ -6,3 +6,5 @@ source-repository-package
|
||||||
type: git
|
type: git
|
||||||
location: https://git.rhiannon.website/rhi/svg-builder
|
location: https://git.rhiannon.website/rhi/svg-builder
|
||||||
tag: 1cbcd594d3009f9fd71f253b52ac82673bf5482e
|
tag: 1cbcd594d3009f9fd71f253b52ac82673bf5482e
|
||||||
|
|
||||||
|
allow-newer: *
|
||||||
|
|
|
@ -8,9 +8,11 @@ import Glosses
|
||||||
import Text.Pandoc.Definition
|
import Text.Pandoc.Definition
|
||||||
import Text.Pandoc.JSON
|
import Text.Pandoc.JSON
|
||||||
import Text.Pandoc.Walk
|
import Text.Pandoc.Walk
|
||||||
|
import Data.Maybe
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
import Control.Applicative
|
|
||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
|
import Control.Applicative
|
||||||
|
import Control.Monad
|
||||||
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
|
@ -19,6 +21,7 @@ main = toJSONFilter filter where
|
||||||
lang' <- toLang $ Map.lookup "conlang" m
|
lang' <- toLang $ Map.lookup "conlang" m
|
||||||
let ?lang = lang'
|
let ?lang = lang'
|
||||||
fmap (walk makeEbnf .
|
fmap (walk makeEbnf .
|
||||||
|
walk makeQuotes .
|
||||||
walk (concatMap makeBlocks) .
|
walk (concatMap makeBlocks) .
|
||||||
walk inlineLetterList) $
|
walk inlineLetterList) $
|
||||||
walkM spans =<<
|
walkM spans =<<
|
||||||
|
@ -39,12 +42,30 @@ makeBlocks :: Block -> [Block]
|
||||||
makeBlocks (Div ("", clss, []) blks)
|
makeBlocks (Div ("", clss, []) blks)
|
||||||
| Just (cls, rest) <- pluck1 ["figure", "aside"] clss =
|
| Just (cls, rest) <- pluck1 ["figure", "aside"] clss =
|
||||||
let html = RawBlock $ Format "html"
|
let html = RawBlock $ Format "html"
|
||||||
open = html $ "<" <> cls <> " class='" <> Text.unwords rest <> "'>"
|
open = if null rest then
|
||||||
|
html $ "<" <> cls <> ">"
|
||||||
|
else
|
||||||
|
html $ "<" <> cls <> " class='" <> Text.unwords rest <> "'>"
|
||||||
close = html $ "</" <> cls <> ">"
|
close = html $ "</" <> cls <> ">"
|
||||||
in
|
in
|
||||||
[open] ++ blks ++ [close]
|
[open] ++ blks ++ [close]
|
||||||
makeBlocks b = [b]
|
makeBlocks b = [b]
|
||||||
|
|
||||||
|
makeQuotes :: Block -> Block
|
||||||
|
makeQuotes para@(Para b) = fromMaybe para $ do
|
||||||
|
inner <- split b
|
||||||
|
return (BlockQuote [Para inner])
|
||||||
|
where
|
||||||
|
isDelim str = str == "\"\"\"" || str == "““”" -- lol
|
||||||
|
|
||||||
|
split (Str begin:SoftBreak:rest) = guard (isDelim begin) *> checkEnd rest
|
||||||
|
split _ = empty
|
||||||
|
|
||||||
|
checkEnd [SoftBreak, Str end] = [] <$ guard (isDelim end)
|
||||||
|
checkEnd (start:rest) = (start :) <$> checkEnd rest
|
||||||
|
checkEnd _ = empty
|
||||||
|
makeQuotes other = other
|
||||||
|
|
||||||
|
|
||||||
inlineLetterList :: Block -> Block
|
inlineLetterList :: Block -> Block
|
||||||
inlineLetterList (Div a@(_, cs, _) blks)
|
inlineLetterList (Div a@(_, cs, _) blks)
|
||||||
|
|
|
@ -13,20 +13,22 @@ import qualified Data.Text as Text
|
||||||
spans :: Vars => Inline -> IO Inline
|
spans :: Vars => Inline -> IO Inline
|
||||||
spans = \case
|
spans = \case
|
||||||
Code attrs txt
|
Code attrs txt
|
||||||
| Just ('\\', txt') <- Text.uncons txt -> pure $ Code attrs txt'
|
| Just ('\\', txt') <- Text.uncons txt -> pure $ Code attrs txt'
|
||||||
| Just txt' <- enclosed "⫽" "⫽" txt -> pure $ ipaA txt'
|
| Just txt' <- enclosed "⫽" "⫽" txt -> pure $ ipaA txt'
|
||||||
| Just txt' <- enclosed "//" "//" txt -> pure $ ipaA txt'
|
| Just txt' <- enclosed "//" "//" txt -> pure $ ipaA txt'
|
||||||
| Just _ <- enclosed "/" "/" txt -> pure $ ipaB txt
|
| Just _ <- enclosed "/" "/" txt -> pure $ ipaB txt
|
||||||
| Just _ <- enclosed "[" "]" txt -> pure $ ipaN txt
|
| Just _ <- enclosed "[" "]" txt -> pure $ ipaN txt
|
||||||
| Just txt' <- enclosed "{" "}" txt -> lang txt'
|
| Just txt' <- enclosed "{" "}" txt -> lang txt'
|
||||||
| Just txt' <- enclosed "!" "!" txt -> pure $ abbr txt'
|
| Just txt' <- enclosed "!" "!" txt -> pure $ abbr txt'
|
||||||
|
| Just txt' <- enclosed "*" "*" txt -> pure $ mark txt'
|
||||||
i -> pure i
|
i -> pure i
|
||||||
|
|
||||||
ipaA, ipaB, ipaN, abbr :: Text -> Inline
|
ipaA, ipaB, ipaN, abbr, mark :: Text -> Inline
|
||||||
ipaA = Span (cls ["ipa", "ipa-arch"]) . text' . surround "⫽"
|
ipaA = Span (cls ["ipa", "ipa-arch"]) . text' . surround "⫽"
|
||||||
ipaB = Span (cls ["ipa", "ipa-broad"]) . text'
|
ipaB = Span (cls ["ipa", "ipa-broad"]) . text'
|
||||||
ipaN = Span (cls ["ipa", "ipa-narrow"]) . text'
|
ipaN = Span (cls ["ipa", "ipa-narrow"]) . text'
|
||||||
abbr = Span (cls ["abbr"]) . text' . endash
|
abbr = Span (cls ["abbr"]) . text' . endash
|
||||||
|
mark txt = RawInline "html" $ "<mark>" <> txt <> "</mark>"
|
||||||
|
|
||||||
surround :: Text -> Text -> Text
|
surround :: Text -> Text -> Text
|
||||||
surround s txt = s <> txt <> s
|
surround s txt = s <> txt <> s
|
||||||
|
|
|
@ -25,6 +25,9 @@ mansi:
|
||||||
d:
|
d:
|
||||||
- read
|
- read
|
||||||
- understand
|
- understand
|
||||||
|
- manna:
|
||||||
|
d: ok
|
||||||
|
n: (from mansina)
|
||||||
e:
|
e:
|
||||||
o: bairusinabu, ŕminu, mansisinabutul
|
o: bairusinabu, ŕminu, mansisinabutul
|
||||||
t: i (tried to) read it but I didn't understand
|
t: i (tried to) read it but I didn't understand
|
||||||
|
@ -115,8 +118,8 @@ kalń:
|
||||||
t: n
|
t: n
|
||||||
d: cat
|
d: cat
|
||||||
|
|
||||||
kautu:
|
rawŕ:
|
||||||
p: ˈkaw.tu
|
p: ra.wr̩
|
||||||
t: n
|
t: n
|
||||||
d: dragon
|
d: dragon
|
||||||
|
|
||||||
|
@ -185,7 +188,8 @@ parai:
|
||||||
- write
|
- write
|
||||||
- "lisla parai":
|
- "lisla parai":
|
||||||
- rewrite
|
- rewrite
|
||||||
- 'translate (from: INABL)'
|
- d: translate
|
||||||
|
n: 'from: INABL'
|
||||||
|
|
||||||
ustai:
|
ustai:
|
||||||
p: ˈus.tai
|
p: ˈus.tai
|
||||||
|
|
Loading…
Reference in New Issue