LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback
User Name
Password
LQ Suggestions & Feedback Do you have a suggestion for this site or an idea that will make the site better? This forum is for you.
PLEASE READ THIS FORUM - Information and status updates will also be posted here.

Notices


Reply
  Search this Thread
Old 04-09-2017, 02:06 AM   #16
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255

Quote:
Originally Posted by Sefyir View Post
I don't know about pdf or epub, but a plain text export feature would be nice.
Not to hard to convert from plain text to any format
It is more or less not that extremely complicated. I found yesterday.

1) First step is to wget without pictures the thread in print mode. You need an HTML file, since it is even nicer.
http://www.linuxquestions.org/questi...5602548-print/

2) html2xhtml to make chapter.xhtml file.
Code:
html2xhtml thread.html > chapter.xhtml
3) copy the file to chapter.xhtml into OEBP directory. here the example: https://github.com/spartrekus/basic-epub-example

4) into bash, type:
makefile

5) Upload it onto your ftp favorite website, and download it from your Linux Ebook reader, read, rocking chair, drink coffee and relax at the sun.

Et Voila !

Last edited by Xeratul; 04-09-2017 at 02:09 AM.
 
Old 04-10-2017, 12:25 AM   #17
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 634

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
Quote:
Originally Posted by Xeratul View Post
It is more or less not that extremely complicated. I found yesterday.

1) First step ...
I don't mean to one-up you, but your post inspired me to create a simpler solution
It uses pandoc, so you may need to install it. Defaults out index.epub if you don't define output file.

Code:
# Usage: html2epub URL output.epub
html2epub() { url="$(echo "$(grep -oE '.*[0-9]{4,}' <<< "$1")"'-print/?pp=50')" && pandoc -f html -t epub3 -o "${2:-index.epub}" <(wget -q "$url" -O -); }

html2epub 'https://www.linuxquestions.org/questions/lq-suggestions-and-feedback-7/lq-option-to-export-a-thread-to-epub-format-to-read-later-in-travel-4175602548/' mybook.epub
Sometimes pandoc sends out this error message though, not sure why.
Code:
pandoc: Cannot decode byte '\x99': Data.Text.Internal.Encoding.Fusion.streamUtf8: Invalid UTF-8 stream
EDIT:

For the truly adventurous, this is my first usage of >() and will host the file using woof at http://lanaddr:8080 to be accessed (seems to fail more often though)
Code:
html2epub() { url="$(echo "$(grep -oE '.*[0-9]{4,}' <<< "$1")"'-print/?pp=50')" && pandoc -f html -t epub3 -o >(woof -) <(wget -q "$url" -O -); }

Last edited by Sefyir; 04-10-2017 at 12:48 AM.
 
Old 04-10-2017, 10:13 AM   #18
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by Sefyir View Post
I don't mean to one-up you, but your post inspired me to create a simpler solution
very good!!!

Pandoc is not reliable, unfortunately, and you can get several issues such as encoding. Likely, the best is to try to use C or C++, to make clean conversion, since the conversion is not complicated. It is a bad choice to use pandoc for making an epub, which is just a ZIP file.

My way is the following:
(1) You don't need pandoc.
(2) You need only GCC + ZIP installed, and nothing else to do a clean job of any types of HTML to beautifully made EPUB.

Last edited by Xeratul; 04-10-2017 at 10:18 AM.
 
Old 04-15-2017, 02:04 PM   #19
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by Sefyir View Post
I don't know about pdf or epub, but a plain text export feature would be nice.
Not to hard to convert from plain text to any format
Not true Just right now fighting with ^L, ^B just to make an EPUB !!
Code:
ncpcln file.in file.cleaned
Code:
 

//////////////////
// NCPCLN
void ncpcln( char *filetarget,  char *  filesource ){
  // fread
  char buffer[1];
  char outchar[1];
  size_t          n;
  size_t          m;
  FILE *fp;
  FILE *fp1; 
  FILE *fp2;
  int counter = 0 ; 
  int freader = 1 ; 
  int i , j ,posy, posx ; 
  if ( fexist( filesource ) == 1 ){
        fp = fopen( filesource, "rb");
        fp2 = fopen( filetarget, "wb");
        counter = 0; 
        while(  !feof(fp) && ( freader == 1)   ) {
           if (  feof(fp)   ) {
                freader = 0 ; 
            }
            n = fread(  buffer, sizeof(char), 1 , fp);

            for( i = 1 ; i <= 26 ; i++)
	    {
	      if ( buffer[ 0 ] == i )  // >
	      {
	       outchar[0] = ' '; 
               m = fwrite( outchar , sizeof(char), 1,  fp2);
	      }
	    }

	    if ( buffer[ 0 ] == 0x0c )  // 0a 0c ^L 
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x2b )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x01 )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x02 )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x03 )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x04 )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x05 )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x06 )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x07 )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x26 )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x3e )  // >
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else if ( buffer[ 0 ] == 0x3c )  // < 
	    {
	     outchar[0] = ' '; 
             m = fwrite( outchar , sizeof(char), 1,  fp2);
	    }
	    else
              m = fwrite( buffer, sizeof(char), 1,  fp2);
        }
        fclose(fp2);
        fclose(fp);
      }
}
this will allow to make a cleaned plain text file.

Then you can bring it into it in the <middle>


Code:
<?xml version="1.0" encoding="iso-8859-1"?>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title> New Section </title>
  </head>
  <body>
    <h1>
      doc using plaintext file
    </h1>


  <here it is the middle >

  </body>
</html>


It is not that easy to made an epub by hand

Last edited by Xeratul; 04-15-2017 at 02:08 PM.
 
Old 04-16-2017, 05:39 AM   #20
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
- Let's forget guys about EPUB. EPUB is not a good format for this aim.
- PDF with "reflow" option is not good either.

It makes no senses, since this EPUB is built on xhtml+xml.

Here's a list of major browser standards introduced roughly after Netscape 3 (when I started noticing browser devolution):
Quote:
PNG
HTML 4.01
CSS1
PHP
JAVA
DOM / DHTML
XHTML
CSS2
SVG

After studying the question on this website https://en.wikipedia.org/wiki/Compar...e-book_formats, it seems that open source free ebook format GNU is not available.
Probably the best is to make export to DOC since it is old, outdated, but however it is fairly readily stable on an ebook. Whatever encoding it works. When I have strange chars between 0x02 and 0x26, it hangs pretty well. Epub with too many pages are also not readily working.
https://msdn.microsoft.com/en-us/lib...ffice.12).aspx

Last edited by Xeratul; 04-16-2017 at 09:00 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] difficulty downloading epub format Brant Linux - Software 6 07-31-2016 08:02 PM
okular plugin for epub format StefanP Linux - Newbie 3 10-22-2014 01:52 AM
Is there a way to export pdf files to mobi or epub without weird artifacts/characters linux_BSD Linux - Software 7 10-20-2012 06:01 PM
LibreOffice Writer and Calibre and EPUB format SaintDanBert Linux - Software 3 06-06-2011 04:59 PM

LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback

All times are GMT -5. The time now is 06:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration