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
|
||||
location: https://git.rhiannon.website/rhi/svg-builder
|
||||
tag: 1cbcd594d3009f9fd71f253b52ac82673bf5482e
|
||||
|
||||
allow-newer: *
|
||||
|
|
|
@ -8,9 +8,11 @@ import Glosses
|
|||
import Text.Pandoc.Definition
|
||||
import Text.Pandoc.JSON
|
||||
import Text.Pandoc.Walk
|
||||
import Data.Maybe
|
||||
import qualified Data.Map as Map
|
||||
import Control.Applicative
|
||||
import qualified Data.Text as Text
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
|
||||
|
||||
main :: IO ()
|
||||
|
@ -19,6 +21,7 @@ main = toJSONFilter filter where
|
|||
lang' <- toLang $ Map.lookup "conlang" m
|
||||
let ?lang = lang'
|
||||
fmap (walk makeEbnf .
|
||||
walk makeQuotes .
|
||||
walk (concatMap makeBlocks) .
|
||||
walk inlineLetterList) $
|
||||
walkM spans =<<
|
||||
|
@ -39,12 +42,30 @@ makeBlocks :: Block -> [Block]
|
|||
makeBlocks (Div ("", clss, []) blks)
|
||||
| Just (cls, rest) <- pluck1 ["figure", "aside"] clss =
|
||||
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 <> ">"
|
||||
in
|
||||
[open] ++ blks ++ [close]
|
||||
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 (Div a@(_, cs, _) blks)
|
||||
|
|
|
@ -13,20 +13,22 @@ import qualified Data.Text as Text
|
|||
spans :: Vars => Inline -> IO Inline
|
||||
spans = \case
|
||||
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 _ <- enclosed "/" "/" txt -> pure $ ipaB txt
|
||||
| Just _ <- enclosed "[" "]" txt -> pure $ ipaN txt
|
||||
| Just txt' <- enclosed "{" "}" txt -> lang txt'
|
||||
| Just txt' <- enclosed "!" "!" txt -> pure $ abbr txt'
|
||||
| Just txt' <- enclosed "*" "*" txt -> pure $ mark txt'
|
||||
i -> pure i
|
||||
|
||||
ipaA, ipaB, ipaN, abbr :: Text -> Inline
|
||||
ipaA, ipaB, ipaN, abbr, mark :: Text -> Inline
|
||||
ipaA = Span (cls ["ipa", "ipa-arch"]) . text' . surround "⫽"
|
||||
ipaB = Span (cls ["ipa", "ipa-broad"]) . text'
|
||||
ipaN = Span (cls ["ipa", "ipa-narrow"]) . text'
|
||||
abbr = Span (cls ["abbr"]) . text' . endash
|
||||
mark txt = RawInline "html" $ "<mark>" <> txt <> "</mark>"
|
||||
|
||||
surround :: Text -> Text -> Text
|
||||
surround s txt = s <> txt <> s
|
||||
|
|
|
@ -25,6 +25,9 @@ mansi:
|
|||
d:
|
||||
- read
|
||||
- understand
|
||||
- manna:
|
||||
d: ok
|
||||
n: (from mansina)
|
||||
e:
|
||||
o: bairusinabu, ŕminu, mansisinabutul
|
||||
t: i (tried to) read it but I didn't understand
|
||||
|
@ -115,8 +118,8 @@ kalń:
|
|||
t: n
|
||||
d: cat
|
||||
|
||||
kautu:
|
||||
p: ˈkaw.tu
|
||||
rawŕ:
|
||||
p: ra.wr̩
|
||||
t: n
|
||||
d: dragon
|
||||
|
||||
|
@ -185,7 +188,8 @@ parai:
|
|||
- write
|
||||
- "lisla parai":
|
||||
- rewrite
|
||||
- 'translate (from: INABL)'
|
||||
- d: translate
|
||||
n: 'from: INABL'
|
||||
|
||||
ustai:
|
||||
p: ˈus.tai
|
||||
|
|
Loading…
Reference in New Issue