Non-English Tag

42 views
Skip to first unread message

Haisheng Wu

unread,
Apr 16, 2011, 10:34:57 PM4/16/11
to hakyll

What if I need non-English tags, for instance Chinese tags, what I
should do to make it work?
I'm a haskell newbie..

I took a quick try, seems the only problem is that while auto
generating html file for each tag,
it did not put the Chinese characters as file name.
While I manually fix the generated html file name, it works well.

Any ideas?

Thanks in advance!

Jasper Van der Jeugt

unread,
Apr 17, 2011, 2:38:18 AM4/17/11
to hak...@googlegroups.com, Haisheng Wu
Hello,

I quickly tried to reproduce it here, the tag files *did* seem to get
written, however, the preview server could not find them. Anyway, I
suppose this depends a lot on the used file system... could you give
us some more details?

* what are the tags?
* what filenames *does* hakyll generate?
* if possible, could you provide the source code?

Cheers,
Jasper

Lubomír Sedlář

unread,
Apr 17, 2011, 5:13:43 AM4/17/11
to hak...@googlegroups.com
Hello,
I faced something like this — I use hakyll to generate website in Czech
and tags with some special characters (like ěščřžýáíé) caused problems.
The solution I used was to define custom route that stripped those
characters. Maybe you could use similar approach.

> match "tags/*" $ do
> route $ customRoute tagToRoute
> ...

> tagToRoute :: Identifier -> FilePath
> tagToRoute = (++".html") . map toLower . stripDiacritics . toFilePath
>
> stripDiacritics :: String -> String
> stripDiacritics str = foldl (\s (f,t) -> replace f t s) str diacritics
>
> replace :: Eq a => a -> a -> [a] -> [a]
> replace _ _ [] = []
> replace f r (x:xs)
> | f == x = r : replace f r xs
> | otherwise = x : replace f r xs
>
> diacritics :: [(Char, Char)]
> diacritics = [ ('ě', 'e'), ('š', 's'), ('č', 'c'), ('ř', 'r'),
> ('ž', 'z'), ('ý', 'y'), ('á', 'a'), ('í', 'i'),
> ('é', 'e')]

Haisheng Wu píše v So 16. 04. 2011 v 19:34 -0700:

Haisheng Wu

unread,
Apr 17, 2011, 6:11:37 AM4/17/11
to hakyll
Thanks and sounds good for only few tags!

Haisheng Wu

unread,
Apr 17, 2011, 8:08:43 AM4/17/11
to hakyll
Thanks Lubomír Sedlář. The "work around" works for me.

Another question comes up:
`(++".html")` turns out to be something duplicated impl with
`(setExtension "html")`

Are we able to glue Routes together as Arrows or Monad like what
Compiler in Hakyll?
I mean something like below:
~~~~~~
route $ do customeRoute myRoute
>>= (setExtension "html")
~~~~~~

thanks.

Jasper Van der Jeugt

unread,
Apr 17, 2011, 8:20:35 AM4/17/11
to hak...@googlegroups.com

Hello,

You can use composeRoutes [1] for this purpose

[1]: http://jaspervdj.be/hakyll/reference/Hakyll-Core-Routes.html

Cheers,
Jasper

On Apr 17, 2011 2:08 PM, "Haisheng Wu" <fre...@gmail.com> wrote:

Haisheng Wu

unread,
Apr 17, 2011, 8:49:37 AM4/17/11
to hakyll
Really cool...and sorry for answering such naive question..

BTW, did you have any update on the first problem?
I means failed to generate non-English tag page.

Jasper Van der Jeugt

unread,
Apr 17, 2011, 9:00:54 AM4/17/11
to hak...@googlegroups.com

Haven't had any access to my development machine. I hope to resolve it tomorrow.

Cheers,
Jasper

Haisheng Wu

unread,
Apr 16, 2012, 10:40:09 AM4/16/12
to Jasper Van der Jeugt, hak...@googlegroups.com
Hello Jasper,
You could find source code at :
https://github.com/freizl/dive-into-haskell/tree/master/web/hakyll/hakyllsample.

I'm tested at platform: ubuntu 10.11, ghc-7.0.3, hakyll-3.2.6.1
You could find near line 48 in order to reproduce the issue.

I'm trying to dig the cause. If you would like to help it out, that
will be great!

Thanks.
-Simon


On Apr 17 2011, 2:38 pm, Jasper Van der Jeugt <jasper...@gmail.com>
wrote:


> Hello,
>
> I quickly tried to reproduce it here, the tag files *did* seem to get
> written, however, the preview server could not find them. Anyway, I
> suppose this depends a lot on the used file system... could you give
> us some more details?
>
> * what are the tags?
> * what filenames *does* hakyll generate?
> * if possible, could you provide the source code?
>
> Cheers,
> Jasper
>
>
>
>
>
>
>
> On Sun, Apr 17, 2011 at 4:34 AM, Haisheng Wu <fre...@gmail.com> wrote:
>

> > What if I neednon-Englishtags, for instance Chinese tags, what I

Haisheng Wu

unread,
Apr 17, 2012, 9:08:12 AM4/17/12
to hakyll
This is a actually a old bug regarding to ghc which has been fixed
ghc-7.2.x.

Since I'm still using ghc-7.0.2, I need a workaround which not
supposed to be into hakyll.
http://stackoverflow.com/questions/10191171/prelude-writefile-with-a-chinese-file-name


-Simon

On Apr 16, 10:40 pm, Haisheng Wu <fre...@gmail.com> wrote:
> Hello Jasper,
>   You could find source code at :https://github.com/freizl/dive-into-haskell/tree/master/web/hakyll/ha....

CCH C

unread,
Apr 18, 2012, 11:00:16 PM4/18/12
to hak...@googlegroups.com
hi, I encountered exactly the same problem, and patched hakyll source code. Please use my forked source code on Github. https://github.com/hwa/hakyll
Reply all
Reply to author
Forward
0 new messages