summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Pancake/Printing.hs1
-rw-r--r--Pancake/Rendering.hs5
-rw-r--r--pancake.el13
3 files changed, 15 insertions, 4 deletions
diff --git a/Pancake/Printing.hs b/Pancake/Printing.hs
index c16e820..bace403 100644
--- a/Pancake/Printing.hs
+++ b/Pancake/Printing.hs
@@ -89,6 +89,7 @@ showSexps uri ro =
, showSexp s]
showDenotation :: Denotation -> String
showDenotation (Link u) = list ["link", ".", encodeStr $ show u]
+ showDenotation (Image u) = list ["image", ".", encodeStr $ show u]
showDenotation (Math m) = list ["math", ".", encodeStr m]
showDenotation (Heading l) = list ["heading", ".", show l]
diff --git a/Pancake/Rendering.hs b/Pancake/Rendering.hs
index 5393b77..e5c5ae4 100644
--- a/Pancake/Rendering.hs
+++ b/Pancake/Rendering.hs
@@ -42,6 +42,7 @@ data Listing = Bulleted
-- | Denotations: information that can be ignored, but can also be
-- used to improve the UI.
data Denotation = Link URI
+ | Image URI
| Math String
| Heading Int
deriving (Show, Eq)
@@ -336,7 +337,7 @@ readInline (P.Link attr alt (url, title)) = do
(URI "" Nothing "" "" ('#':_)) -> Magenta
_ -> Cyan
st <- get
- pure $ (map $ Denote (Link uri) . Fg color) t ++
+ pure $ map (Denote (Link uri) . Fg color) t ++
[Fg Blue $ fromString
(concat ["[", showRef (referenceDigits $ rsConf st) cnt, "]"])]
Nothing -> pure [fromString title]
@@ -353,7 +354,7 @@ readInline (P.Image attr alt (url, title)) = do
(_, alt') -> alt'
cnt <- storeLink uri
st <- get
- pure $ (map $ Denote (Link uri) . Fg Cyan) t ++
+ pure $ map (Denote (Image uri) . Fg Cyan) t ++
[Fg Blue $ fromString
(concat ["[", showRef (referenceDigits $ rsConf st) cnt, "]"])]
readInline (P.Note bs) = do
diff --git a/pancake.el b/pancake.el
index b56e417..46d0ddb 100644
--- a/pancake.el
+++ b/pancake.el
@@ -175,7 +175,7 @@
(defun pancake-button-action (button)
"An action to be invoked on button activation."
- (funcall 'browse-url (button-get button 'uri)))
+ (funcall 'browse-url (button-get button 'pancake-uri)))
(defun pancake-print-elem (element)
"Translate ELEMENT into a string."
@@ -204,7 +204,16 @@
(`(denotation (link . ,uri) . ,rest)
(pancake-print-line rest)
(make-text-button start (point)
- 'uri uri
+ 'pancake-uri uri
+ 'pancake-type 'link
+ 'help-echo uri
+ 'follow-link t
+ 'action #'pancake-button-action))
+ (`(denotation (image . ,uri) . ,rest)
+ (pancake-print-line rest)
+ (make-text-button start (point)
+ 'pancake-uri uri
+ 'pancake-type 'image
'help-echo uri
'follow-link t
'action #'pancake-button-action))