-
Notifications
You must be signed in to change notification settings - Fork 409
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
org-mode metadata not recognized #700
Comments
Hi, I guess you may like a custom compiler like this: fromOrgCompiler :: Item String -> Compiler (Item String)
fromOrgCompiler = pure . fmap (\s -> (metadatasToStr . orgMetadatas) s ++ s)
orgMetadatas :: String -> [String]
orgMetadatas = map (format . lower . clean) . takeWhile (/= "") . lines
where
clean = concat . splitOn ">" . concat . splitOn "#+" . concat . splitOn "<"
lower s = (map toLower . takeWhile (/= ':')) s ++ dropWhile (/= ':') s
-- | Custom format every metadata.
format xs@('d' : 'a' : 't' : 'e' : _) = take 16 xs -- drop weekday str. 2018-05-03 Thu -> 2018-05-03
format a = a
metadatasToStr :: [String] -> String
metadatasToStr = ("----------\n" ++) . (++ "----------\n") . unlines It can generate simple metadata from org format.
To use it, just: If you need tags, you may first generate temp org files to match "posts/*.org" $ do
route $ customRoute (\i -> ".." </> "_temp" </> toFilePath i)
compile $ getResourceString >>= fromOrgCompiler then tags <- buildTags "_temp/posts/*.org" (fromCapture "tags/*.html") |
Indeed, you need to run I am modifying my blog these days, which is using this method. When I finish it, I guess, it can give you an example. BTW, in my present blog, I use Python to generate org files with metadata first, and then My method above just approaches this process with Haskell. |
@HaoZeke See the example here: https://github.com/nasyxx/NasyMoe/ L244-L258 The fromOrgCompiler L90-L93 Add metadata to org files and copy them to You need to |
Thanks so much! @NasyMoe, it's a really sweet setup B)
…On 4/29/19 7:04 AM, Nasy wrote:
@HaoZeke <https://github.com/HaoZeke>
Hello, I have finished it, generate the metadata from org files.
See the example here:
https://github.com/nasyxx/NasyMoe/
L244-L258
<https://github.com/nasyxx/NasyMoe/blob/master/src/Site.hs#L244-L258>
The fromOrgCompiler
L90-L93
<https://github.com/nasyxx/NasyMoe/blob/master/src/Site.hs#L90-L93>
Add metadata to org files and copy them to |_temp|
You need to |stack exec site rebuild| twice. The first time to
generate org files with metadata to |_temp|, and the second time build
website from _temp.
???
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#700 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABBCUTYCUL5TQELOW5IEPSLPSZGAVANCNFSM4HDSXEHQ>.
|
Yes, agree that Hakyll should really use Pandoc's metadata parser if it's not in standard YAML format and make it available. The problem is that Hakyll assumes it can read the metadata before actually reading the file content (as an optimization), so this might make it a bit tricky to implement. |
Any news on this? I was planning to use hakyll mostly to deal with Pandoc + org mode, and I'm quite surprised by that issue. |
I'm not using Hakyll these days, but in the past I've hacked around this for my blog by messing with Metadata, in case it might help https://github.com/karlicoss/beepb00p/blob/c522970bd8b1cfb6ffb3c8245bdcb57243a87570/hakyll/Org.hs#L36-L38 |
Hi, is this feature still doable in 2021 ? Thanks |
@apraga No-one seem to work on it at the moment, so feel free to try. Also, the workaround provided above might work for you, have you tried that? |
@Minoru At the second try, I managed to make the workaround works after a slight modification :
For tackling the issue properly, it looks like my skills are not enough :( |
There is also this solution here, which does not require running the site build twice: #780 |
Hi. I noticed that even though
pandoc
correctly recognizes the following as metadata:hakyll
does not, instead it requiresyaml
metadata which renders theorg-mode
files to be quite meaningless... I believe this is becausehakyll
uses its own metadata-reader. Sincepandoc
now has better support, might it be used for all metadata?The text was updated successfully, but these errors were encountered: