-
Notifications
You must be signed in to change notification settings - Fork 66
Make link rendering more configurable #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| use flake |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ module Patat.Presentation.Settings | |
|
|
||
| , TransitionSettings (..) | ||
|
|
||
| , LinkPlacement (..) | ||
| , LinkSettings (..) | ||
|
|
||
| , parseSlideSettings | ||
|
|
@@ -313,23 +314,41 @@ instance A.FromJSON TransitionSettings where | |
| TransitionSettings <$> o A..: "type" <*> pure o | ||
|
|
||
|
|
||
| -------------------------------------------------------------------------------- | ||
| data LinkPlacement | ||
| = ReferenceLinkPlacement | ||
| | DropLinkPlacement | ||
| deriving (Eq, Show) | ||
|
|
||
|
|
||
| -------------------------------------------------------------------------------- | ||
| instance A.FromJSON LinkPlacement where | ||
| parseJSON = A.withText "FromJSON LinkPlacement" $ \t -> case t of | ||
| "reference" -> pure ReferenceLinkPlacement | ||
| "drop" -> pure DropLinkPlacement | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps fail if lsOSC == false && lsPlacement == "drop"?
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good idea, I'll add a validation. |
||
| _ -> fail $ "unknown placement: " <> show t | ||
|
|
||
|
|
||
| -------------------------------------------------------------------------------- | ||
| data LinkSettings = LinkSettings | ||
| { lsOSC8 :: !(Maybe Bool) | ||
| { lsOSC8 :: !(Maybe Bool) | ||
| , lsPlacement :: !(Maybe LinkPlacement) | ||
| } deriving (Eq, Show) | ||
|
|
||
|
|
||
| -------------------------------------------------------------------------------- | ||
| instance Semigroup LinkSettings where | ||
| l <> r = LinkSettings | ||
| { lsOSC8 = on mplus lsOSC8 l r | ||
| { lsOSC8 = on mplus lsOSC8 l r | ||
| , lsPlacement = on mplus lsPlacement l r | ||
| } | ||
|
|
||
|
|
||
| -------------------------------------------------------------------------------- | ||
| instance A.FromJSON LinkSettings where | ||
| parseJSON = A.withObject "FromJSON LinkSettings" $ \o -> | ||
| LinkSettings <$> o A..:? "osc8" | ||
| parseJSON = A.withObject "FromJSON LinkSettings" $ \o -> LinkSettings | ||
| <$> o A..:? "osc8" | ||
| <*> o A..:? "placement" | ||
|
|
||
|
|
||
| -------------------------------------------------------------------------------- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,6 +234,7 @@ data Theme = Theme | |
| , themeCode :: !(Maybe Style) | ||
| , themeLinkText :: !(Maybe Style) | ||
| , themeLinkTarget :: !(Maybe Style) | ||
| , themeLinkOSC8 :: !(Maybe Style) -- Undocumented | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to use diffrent style than
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think of this as just extra formatting that gets applied if text gets linked using OSC8, I'm using it to always underline in that case. |
||
| , themeStrikeout :: !(Maybe Style) | ||
| , themeQuoted :: !(Maybe Style) | ||
| , themeMath :: !(Maybe Style) | ||
|
|
@@ -265,6 +266,7 @@ instance Semigroup Theme where | |
| , themeCode = mplusOn themeCode | ||
| , themeLinkText = mplusOn themeLinkText | ||
| , themeLinkTarget = mplusOn themeLinkTarget | ||
| , themeLinkOSC8 = mplusOn themeLinkOSC8 | ||
| , themeStrikeout = mplusOn themeStrikeout | ||
| , themeQuoted = mplusOn themeQuoted | ||
| , themeMath = mplusOn themeMath | ||
|
|
@@ -283,7 +285,7 @@ instance Monoid Theme where | |
| mempty = Theme | ||
| Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing | ||
| Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing | ||
| Nothing Nothing Nothing Nothing Nothing Nothing Nothing | ||
| Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing | ||
|
|
||
| -------------------------------------------------------------------------------- | ||
| defaultTheme :: Theme | ||
|
|
@@ -310,6 +312,7 @@ defaultTheme = Theme | |
| , themeCode = dull Ansi.White `mappend` ondull Ansi.Black | ||
| , themeLinkText = dull Ansi.Green | ||
| , themeLinkTarget = dull Ansi.Cyan `mappend` underline | ||
| , themeLinkOSC8 = underline | ||
| , themeStrikeout = ondull Ansi.Red | ||
| , themeQuoted = dull Ansi.Green | ||
| , themeMath = dull Ansi.Green | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use already existing themeLinkTarget? I see the text would need both styles themeLink and themeLinkTarget merged, but that might be complicated.