public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Writing custom filter in python to remove non-breaking spaces
@ 2017-08-02  9:05 Karim Mohammadi
       [not found] ` <3be5ee09-90dc-41ad-a368-9298b965dfaa-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Karim Mohammadi @ 2017-08-02  9:05 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1360 bytes --]

Hi. I want to convert html file *file1.html* to *file1.tex*. The html file 
contains *&nbsp;* .

How can i write an python script as a filter to remove non-breaking space 
(&nbsp)?

This is my code:

    #!/usr/bin/env python
    
    """
    Pandoc filter to removing &nbsp; string from the text
    """
    
    from pandocfilters import toJSONFilter, Para
    
    def debug(content):
    file = open('debug.txt', 'w')
    for item in content:
    file.write("%s\n" % item)
    
    def nbsp(key, value, format, meta):
    uniString = unicode(value, "UTF-8")
    uniString = value.replace("&nbsp;", " ")
    
    return uniString
    
    if __name__ == "__main__":
    toJSONFilter(nbsp)

 but calling command:

pandoc file1.html --filter ./nbsp.py -o file1.tex

give me some errors.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/3be5ee09-90dc-41ad-a368-9298b965dfaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 8658 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-08-05  8:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-02  9:05 Writing custom filter in python to remove non-breaking spaces Karim Mohammadi
     [not found] ` <3be5ee09-90dc-41ad-a368-9298b965dfaa-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-08-02 14:09   ` John MacFarlane
     [not found]     ` <20170802140916.GF38349-9Rnp8PDaXcadBw3G0RLmbRFnWt+6NQIA@public.gmane.org>
2017-08-03  4:55       ` Karim Mohammadi
     [not found]         ` <cc13bbea-06e5-422b-bcdd-cd9ba1c4cf95-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-08-03  6:11           ` Andrew Dunning
2017-08-03 22:29   ` Kolen Cheung
     [not found]     ` <f0bb6fae-6104-4efc-840d-34fd19b02840-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-08-04 18:58       ` Melroch
     [not found]         ` <CADAJKhBEZ8-BdJTQRJE4M2nettrGKhf1xYzqBYs=pe=_DAodpA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-04 22:03           ` Kolen Cheung
2017-08-04 22:09           ` Kolen Cheung
     [not found]             ` <4abb2571-34b8-4e49-a189-05632083aab9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-08-05  8:45               ` Melroch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).