LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-01-2016, 06:31 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Rep: Reputation: 255Reputation: 255Reputation: 255
Bash script to create a minimalist Epub with "HELLO WORLD"?


Hello

Would you know a bash script to convert "hello world" into an epub.

ex:
Code:
echo "hello world" > myepub.txt
bash mytxttoepub.sh "myepub.txt"
and it'll result into helloworld.epub

an example
https://github.com/rbrito/epub-example/tree/master/EPUB


I remember that epub is just as as format ZIP file!

Herewith there is a complex way.
...
Quote:


Here's an epub 3.0 file that validates with epubcheck 3.0.1 (the current version at the time of writing). There's plenty more info that can (and should) go in there, of course, but you asked for minimums. We'll start with file structure: in the root directory, there's one mimetype file and two folders--the OEBPS and the META-INF. Here's the mimetype file contents:

application/epub+zip

be sure not to have any return/line break characters in there. In the META-INF folder, there's one file, the container.xml:

<?xml version="1.0"?>
<container version="1.0" xmlns="urnasis:names:tcpendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>

In the OEBPS folder, things get slightly more complex. First is the content.opf file:

<?xml version="1.0" encoding="UTF-8" ?>
<package xmlns="http://www.idpf.org/2007/opf" xmlns:dc="http://purl.org/dc/elements/1.1/" unique-identifier="db-id" version="3.0">

<metadata>
<dc:title id="t1">Title</dc:title>
<dc:identifier id="db-id">isbn</dc:identifier>
<meta property="dcterms:modified">2014-03-27T09:14:09Z</meta>
<dc:language>en</dc:language>
</metadata>

<manifest>
<item id="toc" properties="nav" href="toc.xhtml" media-type="application/xhtml+xml" />
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
<item id="template_css" href="template.css" media-type="text/css" />
<item id="hello" href="1_hello.xhtml" media-type="application/xhtml+xml" />
</manifest>

<spine toc="ncx">
<itemref idref="hello" />
</spine>

</package>

Then comes the toc.xhtml file:

<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>toc.xhtml</title>
<link href="template.css" rel="stylesheet" type="text/css" />
</head>

<body>

<nav id="toc" epub:type="toc">
<h1 class="frontmatter">Table of Contents</h1>
<ol class="contents">
<li><a href="1_hello.xhtml">Hello</a></li>
</ol>

</nav>

</body>

</html>

And finally we have the content of the ebook itself, in this case 1_hello.xhtml:

<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>1_hello.xhtml</title>
<link href="template.css" rel="stylesheet" type="text/css" />
</head>

<body>

<h1>Hello World!</h1>

</body>
</html>

As a bonus, there's a toc.ncx file. This is not required to be valid, but it's required if you want the book to have a working Table of Contents on epub 2.0.1 devices (which is pretty much all of them):

<?xml version="1.0" encoding="UTF-8" ?>
<ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/">

<head>
<meta name="dtb:uid" content="isbn"/>
<meta name="dtb:depth" content="1"/>
</head>

<docTitle>
<text></text>
</docTitle>

<navMap>
<navPoint id="hello" playOrder="1">
<navLabel><text>cover</text></navLabel>
<content src="1_hello.xhtml" />
</navPoint>
</navMap>

</ncx>

And there's also the template.css in there, which is just a CSS stylesheet. In this case, it looks like this:

h1 {
text-align: center;
}

And that's it! For more complex stuff, there are a number of free epub 3 samples available at https://code.google.com/p/epub-samples/.
shareimprove this answer

edited Apr 1 '14 at 17:02

answered Mar 27 '14 at 16:33
Tom
3,5671425



I respect the level of effort you put into your answer but you do realize it isn't a valid ePub and you should provide more detail in case someone copies to produce from. – DᴀʀᴛʜVᴀᴅᴇʀ Mar 28 '14 at 1:09


Hmm; validates for me just fine. What errors are you seeing and what version of epubcheck are you using? – Tom Mar 28 '14 at 1:11
2

ill provide an answer with clarity when I have some extra time. – DᴀʀᴛʜVᴀᴅᴇʀ Mar 28 '14 at 1:27
2

Sounds great! That's one of the things the Stack Exchange sites are best for. – Tom Mar 28 '14 at 1:59
1

@Gramps Do these retailers require derivations from resp. additions to the standard? In that case, I would not support your "should be valid across the board" claim. This thinking led us to divergent technology in HTML 4 and consorts. If they don't adhere to the standard, nobody should support them. End of story. – Raphael Mar 28 '14 at 12:43
show 4 more comments
up vote
4
down vote


In regards to my comments about Tom's ePub not validating there is an error in his toc.xhtml on line 13 and should be coded as <li><a href="1_hello.xhtml">Hello</a></li> which will produce the error message from IDPF validator as:

enter image description here

In regards to the version 3.0 ePub I disagree and believe it should be noted that when an ePub is built as ePub 3.0 format ONLY it will not validate other than 3.0 in epubcheck. This can be achieved and tested in the terminal using epubcheck command line (which is a different question).

If the provided ePub is submitted and ran against epubcheck version 2.0 it will fail for the following:

value of attribute "version" is invalid; must be equal to "2.0"
attribute "property" not allowed here; expected attribute "content", "id", "name", "scheme" or "xml:lang"
element "meta" missing required attributes "content" and "name"
text not allowed here; expected the element end-tag
attribute "properties" not allowed here; expected attribute "fallback", "fallback-style", "href", "media-type", "required-modules" or "required-namespace"
element "nav" not allowed anywhere; expected element "address", "blockquote", "del", "div", "dl", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ins", "noscript", "ns:svg", "ol", "p", "pre", "script", "table" or "ul" (with xmlns:ns="http://www.w3.org/2000/svg")
element "nav" not allowed anywhere; expected element "address", "blockquote", "del", "div", "dl", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ins", "noscript", "ns:svg", "ol", "p", "pre", "script", "table" or "ul" (with xmlns:ns="http://www.w3.org/2000/svg")

That displayed my argument with the industry standard is that a version 2.0 ePub CAN be built to support and function with devices that run version 3.0 and it should be coded as such for quality and validation.

Also, if we are talking about what the structure of ePubs are. Using a OEBPS file structure was technically meant for ePub's in version 1. Since it really doesn't matter what the file structure is as long as the container.xml points and finds a true .opf file I petition and build my ePubs like so:

META-INF
-container.xml
xhtml
-toc.xhtml
-.xhtml files
css
-stylesheet.css
content.opf
toc.ncx
mimetype

I find it easier for maintenance and less annoying searching for a .opf or .ncx file in either OEBPS, OPS, OPF, etc. etc. file structures.

Also Im a big fan of commenting my code and since it will not change the performance I code my manifest as such:

<manifest>
<!-- .ncx -->
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />

<!-- .xhtml -->
<item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" />
<item id="hello" href="1_hello.xhtml" media-type="application/xhtml+xml" />

<!-- .css -->
<item id="css_file" href="stylesheet.css" media-type="text/css" />
</manifest>

shareimprove this answer

edited Mar 31 '14 at 18:57

answered Mar 31 '14 at 18:38

Last edited by Xeratul; 10-01-2016 at 06:32 AM.
 
Old 10-01-2016, 07:00 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
I am guessing you have searched and not found a pre-written solution.

As it sounds like a good little challenge ... what have you done to solve it? (apart from ask here to have it done)
 
Old 10-01-2016, 07:04 AM   #3
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by grail View Post
I am guessing you have searched and not found a pre-written solution.

As it sounds like a good little challenge ... what have you done to solve it? (apart from ask here to have it done)
You are so funny. Maybe you aren't capable to code in SH/BASH or even better in C/C++ to make it?

I just wonder why there is nothing else than pandoc, since it is so simple to make EPUB by hand.
 
Old 10-01-2016, 08:11 AM   #4
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,678

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
Quote:
Originally Posted by Xeratul View Post
You are so funny. Maybe you aren't capable to code in SH/BASH or even better in C/C++ to make it?

I just wonder why there is nothing else than pandoc, since it is so simple to make EPUB by hand.
Let me get this straight, you have ONE person who is clearly interested in your question and wants to know what you have already done, and .. Are you trying to insult him there?

We are not here to give you canned solutions. You want to solve this, we are interested in helping you get there. First, we need to know what you found, what you have tried, and how well it worked or how it did not. If you insist on being rude, you will not like the few answers.

Have you researched the epub format or searched for epub creator software?
 
1 members found this post helpful.
Old 10-01-2016, 08:15 AM   #5
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by Xeratul View Post
You are so funny. Maybe you aren't capable to code in SH/BASH or even better in C/C++ to make it?

I just wonder why there is nothing else than pandoc, since it is so simple to make EPUB by hand.
Being that you haven't shown any attempt, I don't think you're in a position to say that.
grail hasn't said anything he shouldn't have. You post in the forum for programming help, in which you post the code you have come up with, and where you need the help. It's not "Programming Do It For Me."

You yourself state it is so simple, and yet, you show nothing for it. It is a rather simple task. So start writing, show us where you think you went wrong, and what results you are or are not getting.

http://www.linuxquestions.org/questi...#faq_welcomelq
http://www.catb.org/%7Eesr/faqs/smar....html#courtesy

Last edited by goumba; 10-01-2016 at 08:18 AM.
 
Old 10-01-2016, 09:02 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Quote:
Originally Posted by Xeratul
Maybe you aren't capable to code in SH/BASH
Happy to let the 30+ results from a search of this site speak to my abilities.

One would think after 1600+ posts on this site that you might have learnt how to ask a question in a way that others might assist.

Good luck on your solution.
 
Old 10-01-2016, 10:35 AM   #7
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Uh, use bash to convert document to xml? A good little chalenge indeed...
Unless documents are invariably following the same model, it's going to be tedious
 
Old 10-01-2016, 10:41 AM   #8
Axel van Moorsel
Member
 
Registered: Jan 2011
Location: Netherlands (Zuid Holland)
Distribution: Debian 8
Posts: 31

Rep: Reputation: 4
Hi,

Interesting challenge. After some searching and testing I found a solution that seems to work. This is just a "quick and Dirty" way, where many settings are "default" (like "title", "author"). I think it is very well possible to set these in the script, but for now I wanted to keep it as simple as possible. I used your link https://github.com/rbrito/epub-example/tree/master/EPUB as the base for the files and folders, changing them just a little.

First, because the ePub uses a folder structure, I created a template structure in my home directory:
Code:
~/epub/epub template
~/epub/epub template/META-INF
~/epub/epub template/OEBPS
The space in the folder name "epub template" is intentionally. I don't like folder names with spaces but many people use them, so I wanted to make sure the script works with such folders.
In the folder "epub template" I created a text file "mimetype" with content "application/epub+zip".
In the folder "META-INF" comes a text file "container.xml" with content:
Code:
<?xml version="1.0" encoding="utf-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
   <rootfiles>
      <rootfile full-path="OEBPS/book.opf" media-type="application/oebps-package+xml"/>
   </rootfiles>
</container>
This file i copied without changes from the link you provided.
In the folder "OEBPS" I placed two files: "book.opf" and "book.ncx". These were copied with some changes from the afore mentioned link. content of "books.opf" is:
Code:
<?xml version="1.0" encoding="utf-8"?>
<package version="2.0" xmlns="http://www.idpf.org/2007/opf"
   unique-identifier="abcdef">
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:opf="http://www.idpf.org/2007/opf">
    <dc:title>My Fisrt Epub</dc:title>
    <dc:creator opf:role="aut">Just me</dc:creator>
    <dc:language>en-US</dc:language>
    <dc:identifier id="abcdef">abcdef</dc:identifier>
  </metadata>
  <manifest>
    <item id="myepub" href="myepub.xhtml" media-type="application/xhtml+xml" />
    <item id="ncx"    href="book.ncx"     media-type="application/x-dtbncx+xml" />
  </manifest>
  <spine toc="ncx">
    <itemref idref="myepub" />
  </spine>
</package>
and content of "books.ncx" is:
Code:
<?xml version="1.0" encoding="utf-8"?>
<ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/">
  <head>
    <meta name="dtb:uid" content="abcdef" />
    <meta name="dtb:depth" content="1" />
    <meta name="dtb:totalPageCount" content="0" />
    <meta name="dtb:maxPageNumber" content="0" />
  </head>
  <docTitle>
    <text>My Fisrt Epub</text>
  </docTitle>
  <navMap>
    <navPoint id="myepub" playOrder="1">
      <navLabel><text>My book</text></navLabel>
      <content src="myepub.xhtml"/>
    </navPoint>
  </navMap>
</ncx>
Finally the script that creates the ePub:
Code:
#!/bin/bash

# Set some Variables
EpubTemplate="~/epub/epub template"
WorkDir="/tmp/epub"
TextFile="~/epub/myepub.txt"         # Name and location of your text file
EpubFile="/ax/wrk/epub/myepub.epub"  # Name and location of where you want your ePub

# If workfolder exist on the system, then exit.
# This ensures that you always work with just the files you need.
# If you are sure this is not necessary, then omit this check.
# You also can delete workfolder if it exists.
# No need to say you should be VERY careful when deleting
# complete folder structures with a script.
if [ -d "$WorkDir" ] ; then echo "Temporary folder ($WorkDir) exists!"; exit; fi

# Copy your epub template to workfolder.
mkdir -pv "$WorkDir"
cp -r "$EpubTemplate" "$WorkDir/myepub"

# Create xhtml document file
echo "<p><pre>" > "$WorkDir/myepub/OEBPS/myepub.xhtml"
cat "$TextFile" >> "$WorkDir/myepub/OEBPS/myepub.xhtml"
echo "</pre></p>" >> "$WorkDir/myepub/OEBPS/myepub.xhtml"

# Create Epub file 
7z a -tzip "$EpubFile" "$WorkDir"/myepub/mimetype
7z a -tzip "$EpubFile" "$WorkDir"/myepub/META-INF
7z a -tzip "$EpubFile" "$WorkDir"/myepub/OEBPS

# Clean up temporary folder
if [ -f "$WorkDir/myepub/OEBPS/myepub.xhtml" ] ; then rm -fr "$WorkDir"; fi
exit
I hope the comments in the script are clear.
Off course the template and the script can be modified for other needs, but I think this is a basic answer to your question.
Hope you'll enjoy using this script as much as I did making it.
 
Old 04-08-2017, 02:23 AM   #9
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

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

I have found a way to do it with a single bash file:

use:
Code:
epub-maker.sh whateverdocumentfile.txt

Code:
#!/bin/bash



echo  =============================
echo  ==== EBOOK-BASH-CREATOR =====
echo  =============================

if [ "$1" = "" ] ; then 
  exit
  break
fi


pwd
mkdir ~/epub/
mkdir -p ~/epub/epub-template
mkdir -p ~/epub/epub-template/META-INF
mkdir -p ~/epub/epub-template/OEBPS

echo "application/epub+zip" >   ~/epub/epub-template/mimetype

echo '<?xml version="1.0" encoding="utf-8"?>' >  ~/epub/epub-template/META-INF/container.xml
echo '<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">'  >>  ~/epub/epub-template/META-INF/container.xml
echo '   <rootfiles>'  >>  ~/epub/epub-template/META-INF/container.xml
echo '      <rootfile full-path="OEBPS/book.opf" media-type="application/oebps-package+xml"/>'   >>  ~/epub/epub-template/META-INF/container.xml
echo '   </rootfiles>'  >>  ~/epub/epub-template/META-INF/container.xml
echo '</container>'   >>  ~/epub/epub-template/META-INF/container.xml

# >> ~/epub/epub-template/OEBPS/books.opf 
# ~/epub/epub-template/OEBPS/books.opf 
# ~/epub/epub-template/OEBPS
#This file i copied without changes from the link you provided.
#In the folder "OEBPS" I placed two files: "book.opf" and "book.ncx". These were copied with some changes from the afore mentioned link. content of "books.opf" is:
#Code:
echo '<?xml version="1.0" encoding="utf-8"?>'   > ~/epub/epub-template/OEBPS/books.opf
echo '<package version="2.0" xmlns="http://www.idpf.org/2007/opf"'   >> ~/epub/epub-template/OEBPS/books.opf
echo '   unique-identifier="abcdef">'   >> ~/epub/epub-template/OEBPS/books.opf
echo '  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/"'   >> ~/epub/epub-template/OEBPS/books.opf
echo '    xmlns:opf="http://www.idpf.org/2007/opf">'   >> ~/epub/epub-template/OEBPS/books.opf
echo '    <dc:title>My Fisrt Epub</dc:title>'   >> ~/epub/epub-template/OEBPS/books.opf
echo '    <dc:creator opf:role="aut">Just me</dc:creator>'   >> ~/epub/epub-template/OEBPS/books.opf
echo '    <dc:language>en-US</dc:language>'   >> ~/epub/epub-template/OEBPS/books.opf
echo '    <dc:identifier id="abcdef">abcdef</dc:identifier>'   >> ~/epub/epub-template/OEBPS/books.opf
echo '  </metadata>'   >> ~/epub/epub-template/OEBPS/books.opf
echo '  <manifest>'   >> ~/epub/epub-template/OEBPS/books.opf
echo '    <item id="myepub" href="myepub.xhtml" media-type="application/xhtml+xml" />'   >> ~/epub/epub-template/OEBPS/books.opf
echo '    <item id="ncx"    href="book.ncx"     media-type="application/x-dtbncx+xml" />'   >> ~/epub/epub-template/OEBPS/books.opf
echo '  </manifest>'   >> ~/epub/epub-template/OEBPS/books.opf
echo '  <spine toc="ncx">'   >> ~/epub/epub-template/OEBPS/books.opf
echo '    <itemref idref="myepub" />'   >> ~/epub/epub-template/OEBPS/books.opf
echo '  </spine>'   >> ~/epub/epub-template/OEBPS/books.opf
echo '</package>'   >> ~/epub/epub-template/OEBPS/books.opf



#and content of "books.ncx" is:
#Code:
echo '<?xml version="1.0" encoding="utf-8"?>'   > ~/epub/epub-template/OEBPS/books.ncx
echo '<ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/">'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '  <head>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '    <meta name="dtb:uid" content="abcdef" />'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '    <meta name="dtb:depth" content="1" />'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '    <meta name="dtb:totalPageCount" content="0" />'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '    <meta name="dtb:maxPageNumber" content="0" />'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '  </head>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '  <docTitle>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '    <text>My Fisrt Epub</text>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '  </docTitle>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '  <navMap>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '    <navPoint id="myepub" playOrder="1">'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '      <navLabel><text>My book</text></navLabel>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '      <content src="myepub.xhtml"/>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '    </navPoint>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '  </navMap>'   >> ~/epub/epub-template/OEBPS/books.ncx
echo '</ncx>'   >> ~/epub/epub-template/OEBPS/books.ncx



echo Set some variables

# Set some Variables
EpubTemplate="$HOME/epub/epub-template"
rm -rf /tmp/epub
WorkDir="/tmp/epub"
mkdir -p "$WorkDir"
TextFile="$1"         # Name and location of your text file
EpubFile="$HOME/epub/book.epub"  # Name and location of where you want your ePub
mkdir "$HOME/epub/"


# If workfolder exist on the system, then exit.
# This ensures that you always work with just the files you need.
# If you are sure this is not necessary, then omit this check.
# You also can delete workfolder if it exists.
# No need to say you should be VERY careful when deleting
# complete folder structures with a script.
# if [ -d "$WorkDir" ] ; then echo "Temporary folder ($WorkDir) exists!"; exit; fi

# Copy your epub template to workfolder.
mkdir -pv "$WorkDir"
mkdir -p  "$WorkDir"

# Create xhtml document file
echo "Working with file $1 as input data text" 
[ -f "$1" ] && echo File Found
mkdir -p    "$WorkDir/myepub/OEBPS/"
echo    "$WorkDir/myepub/OEBPS/"
echo "Use Cat of $TextFile" 

echo "<p><pre>" >    "$WorkDir/myepub/OEBPS/myepub.xhtml"
cat "$TextFile" >>   "$WorkDir/myepub/OEBPS/myepub.xhtml"
echo "</pre></p>" >> "$WorkDir/myepub/OEBPS/myepub.xhtml"
ls -ltra   "$WorkDir/myepub/OEBPS/"


cd 
cd "$WorkDir"/myepub/
rm -rf "/tmp/epub/myepub/
mkdir -p "/tmp/epub/myepub/

echo "Workdir $WorkDir"
cp -r "$EpubTemplate"/*  "$WorkDir/myepub"
echo  "Copy $EpubTemplate to $WorkDir/myepub"


# Create Epub file 
#7zr a -tzip "$EpubFile" "$WorkDir"/myepub/mimetype
#7zr a -tzip "$EpubFile" "$WorkDir"/myepub/META-INF
#7zr a -tzip "$EpubFile" "$WorkDir"/myepub/OEBPS




pwd
 zip -rX "$EpubFile"  mimetype META-INF/ OEBPS/
 ls -ltra "$EpubFile"

echo "Working with the files $EpubFile" "$WorkDir"/myepub/OEBPS

pwd
echo "File Epub: $EpubFile done."


# Clean up temporary folder
# if [ -f "$WorkDir/myepub/OEBPS/myepub.xhtml" ] ; then rm -fr "$WorkDir"; fi
exit


the pure bash script above is not necessarily working, but thiss one
works : https://github.com/spartrekus/epub-linux-portable-maker

Last edited by Xeratul; 04-08-2017 at 02:59 AM.
 
Old 04-08-2017, 04:56 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ just whack all text in between a <pre></pre> block, haha, that's funny.
sure, it is some kind of "solution"...
and another "in your face" to bloatware like pandoc and incapable people like grail. (*)
Xeratul, you must be so happy right now.

(*) sarcasm! do not take seriously!
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash - Capture "Child" script output with "Parent" without using files or coproc keyword Jason_25 Programming 2 02-14-2016 07:51 PM
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
[SOLVED] How can I edit "EPUB" and "Mobi" files via calibre? hack3rcon Linux - Software 1 02-15-2015 04:42 AM
Create "Hello World" simple window application. eatup Programming 17 04-15-2014 08:15 AM
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 09:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:38 PM.

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