50
淺談開放源碼電子書 ePUB 幕後排版 林彥宏 / 思創軟體

開放源碼電子書與EPUB幕後排版

Embed Size (px)

DESCRIPTION

http://blog.lyhdev.com/2011/12/epub.html

Citation preview

Page 1: 開放源碼電子書與EPUB幕後排版

淺談開放源碼電子書與 ePUB 幕後排版

林彥宏 / 思創軟體

Page 2: 開放源碼電子書與EPUB幕後排版

Who

Lab 雲林科技大學 程式語言教學實驗室

Startup 思創軟體

a Passionate Programmer

[email protected]

Page 3: 開放源碼電子書與EPUB幕後排版

Work 程式語言教學課程 e 化

PLWeb 程式設計練習系統, http://plweb.org/

Page 4: 開放源碼電子書與EPUB幕後排版

程式設計數位教材

Java 數位教材, http://java.plweb.org/

Page 5: 開放源碼電子書與EPUB幕後排版

原始碼Source Code

Page 6: 開放源碼電子書與EPUB幕後排版

*/ if (pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, &eestatus)) { dev_err(&pdev->dev, "Could not read PCI config space for EEPROM Status\n"); return -EIO; }

/* Determine if the error(s) we care about are present. If they are * present we need to fail. */ if (eestatus & 0x4C) { int write_failed = 0; if (pdev->revision == 0x01) { int i; static const u8 eedata[4] = { 0xFE, 0x13, 0x10, 0xFF };

/* Re-write the first 4 bytes if we have an eeprom * present and the revision id is 1, this fixes the * corruption seen with 1310 B Silicon */ for (i = 0; i < 3; i++) if (eeprom_write(adapter, i, eedata[i]) < 0) write_failed = 1; } if (pdev->revision != 0x01 || write_failed) { dev_err(&pdev->dev, "Fatal EEPROM Status Error - 0x%04x\n", eestatus);

/* This error could mean that there was an error * reading the eeprom or that the eeprom doesn't exist. * We will treat each case the same and not try to * gather additional information that normally would * come from the eeprom, like MAC Address */ adapter->has_eeprom = 0; return -EIO; } }

軟體的原始碼

Page 7: 開放源碼電子書與EPUB幕後排版

原始碼

編譯

軟體

Java

JDK

Jar

Java, http://java.com/

Page 8: 開放源碼電子書與EPUB幕後排版

原始碼

編譯

軟體

HTML5CSS3

JavaScript

AppceleratorTitanium

MobileApp

圖片來源:Appcelerator Titanium, http://www.appcelerator.com/

Page 9: 開放源碼電子書與EPUB幕後排版

Write once, run anywhere

Page 10: 開放源碼電子書與EPUB幕後排版

軟體源碼:自動化$ make os=MACOSX

$ make os=LINUX

$ make os=WINDOWS

$ make os=SOLARIS

$ make deploy

$ make money

Page 11: 開放源碼電子書與EPUB幕後排版

軟體源碼:版本控制

畫面擷取自軟體:SourceTree, http://www.sourcetreeapp.com/

Page 12: 開放源碼電子書與EPUB幕後排版

<?xml version="1.0"?><package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId"> <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> <dc:title>Pride and Prejudice</dc:title> <dc:language>en</dc:language> <dc:identifier id="BookId" opf:scheme="ISBN">123456789X</dc:identifier> <dc:creator opf:file-as="Austen, Jane" opf:role="aut">Jane Austen</dc:creator> </metadata> <manifest> <item id="chapter1" href="chapter1.xhtml" media-type="application/xhtml+xml"/> <item id="stylesheet" href="style.css" media-type="text/css"/> <item id="ch1-pic" href="ch1-pic.png" media-type="image/png"/> <item id="myfont" href="css/myfont.otf" media-type="application/x-font-opentype"/> <item id="ncx" href="book.ncx" media-type="application/x-dtbncx+xml"/> </manifest> <spine toc="ncx"> <itemref idref="chapter1" /> </spine> <guide> <reference type="loi" title="List Of Illustrations" href="appendix.html#figures" /> </guide> </package>

電子書的原始碼

Page 13: 開放源碼電子書與EPUB幕後排版

<body> <div class="chapter" title="Chapter&nbsp;1.&nbsp;What Is EPUB 3?"> <div class="titlepage"> <h1 class="title"><a id="what_is_epub_3_question"></a>What Is EPUB 3?</h1> </div>

<div class="sect1" title="EPUB 3 in a Nutshell"> <div class="titlepage"> <h1 class="title"><a id="epub_3_in_a_nutshell"></a>EPUB 3 in a Nutshell</h1> </div>

<p>So what exactly is an EPUB? If you follow electronic publishing at all, you’ve undoubtedly run into the term, but you may have seen or heard it incorrectly being used as a synonym for “ebook”&mdash;as a shorthand for talking about <span class="emphasis"><em>electronic</em></span> <span class="emphasis"><em>books</em></span>. Although the two terms share a common relation in electronic book production, they aren’t interchangeable. EPUB, as we’re here to discover, is a <span class="emphasis"><em>format</em></span> for representing documents in electronic form. “Ebook,” on the other hand, is just an abstract term used to encompass any electronic representation of a book, and includes formats such as PDF, HTML, ASCII text, Word, and a host of others, in addition to EPUB.</p>

電子書示範內容資料來源:O’Reilly, What Is EPUB 3 ?, http://goo.gl/X51CK

Page 14: 開放源碼電子書與EPUB幕後排版

畫面來源:Sigil, http://code.google.com/p/sigil/

Page 15: 開放源碼電子書與EPUB幕後排版

原始碼

編譯

電子書

?

?

eBooks

TXT, EPUB, MOBI, PDF, CHM, ...

Page 16: 開放源碼電子書與EPUB幕後排版

Write once, read anywhere

Page 17: 開放源碼電子書與EPUB幕後排版

$ make type=EPUB

$ make type=EPUB3

$ make type=MOBI

$ make type=KF8

$ make type=PDF

$ make type=HTML

$ make type=CHM

$ make type=TXT

電子書源碼:自動化

$ make publish

$ make money

Page 18: 開放源碼電子書與EPUB幕後排版

電子書源碼:版本控制

我走了,

我揮揮手,

掰掰。

我走了,

正如我來;

我揮揮招手,

掰掰告別西天的雲彩。

輕輕的我走了,

正如我輕輕的來;

我輕輕的招手,

告作別西天的雲彩。

參考資料:徐志摩,再別康橋

Page 19: 開放源碼電子書與EPUB幕後排版

排版 v.s. 結構<h1>What is EPUB?</h1><p>The most widely accepted format for ebooks today is EPUB, which is developed and maintained by the IDPF. You can find the official specification ...

資料來源:Elizabeth Castro, EPUB Straight to the Point

Page 20: 開放源碼電子書與EPUB幕後排版

<h1>What is EPUB?</h1>What is EPUB?(Heading)

What is EPUB?What is EPUB?What is EPUB?What is EPUB?What is EPUB?

Page 21: 開放源碼電子書與EPUB幕後排版

What is EPUB?============

The most widely accepted **format** for ebooks today is EPUB, which is developed and maintained by the IDPF.

Ebook Formats---------------

* epub* pdf* mobi* html

WYSIWYG Plain Text

Page 22: 開放源碼電子書與EPUB幕後排版

Chapter 1. What Is EPUB 3?======================

EPUB 3 in a Nutshell-----------------------------

So what exactly is an EPUB? If you follow electronic publishing at all, youʼve undoubtedly run into the term, but you may have seen or heard it incorrectly being used as a synonym for “ebook” -- as a shorthand for talking about **electronic books**. Although the two terms share a common relation in electronic book production, they arenʼt interchangeable.

記事本

Sigil

Page 23: 開放源碼電子書與EPUB幕後排版

Chapter 1. What Is EPUB 3?======================

EPUB 3 in a Nutshell-----------------------------

So what exactly is an EPUB? If you follow electronic publishing at all, youʼve undoubtedly run into the term, but you may have seen or heard it incorrectly being used as a synonym for “ebook” -- as a shorthand for talking about **electronic books**. Although the two terms share a common relation in electronic book production, they arenʼt interchangeable.

記事本

?

Page 24: 開放源碼電子書與EPUB幕後排版

1989

2010

Page 25: 開放源碼電子書與EPUB幕後排版

Chapter 1. What Is EPUB 3?==========================

EPUB 3 in a Nutshell--------------------

So what exactly is an EPUB? If you follow electronic publishing at all, you’ve undoubtedly run into the term, but you may have seen or heard it incorrectly being used as a synonym for “ebook” -- as a shorthand for talking about **electronic books**. Although the two terms share a common relation in electronic book production, they aren’t interchangeable.

Chapter 1. What Is EPUB 3?======================

EPUB 3 in a Nutshell-----------------------------

So what exactly is an EPUB? If you follow electronic publishing at all, youʼve undoubtedly run into the term, but you may have seen or heard it incorrectly being used as a synonym for “ebook” -- as a shorthand for talking about **electronic books**. Although the two terms share a common relation in electronic book production, they arenʼt interchangeable.

Page 26: 開放源碼電子書與EPUB幕後排版

Markdown

Syntax + Software

Text-to-HTML

easy-to-read

easy-to-write

參考資料:http://daringfireball.net/projects/markdown/

Page 27: 開放源碼電子書與EPUB幕後排版

notepag.es

Page 28: 開放源碼電子書與EPUB幕後排版

語法:標題認識電子書==========

<h1>認識電子書</h1>

電子書的定義------------

<h2>電子書的定義</h2>

參考資料: Markdown 語法說明 http://markdown.tw/ , 電子書的定義 http://goo.gl/0pBEy

Page 29: 開放源碼電子書與EPUB幕後排版

語法:引言

參考資料: http://markdown.tw/ , 荒漠甘泉 http://ce.fhl.net/desert/

> 因我們行事為人、> 是憑著信心、> 不是憑著眼見。> (哥林多後書)

<blockquote>因我們行事為人、是憑著信心、不是憑著眼見。(哥林多後書)</blockquote>

Page 30: 開放源碼電子書與EPUB幕後排版

語法:清單

參考資料: http://markdown.tw/

便當:

* 排骨飯* 雞腿飯* 豬腳飯* 燒肉飯

新書排行榜

1. 賈伯斯傳!2. 華頓商學院最受歡迎的談判課!3. 洋蔥炒蛋到小英便當4. 吾命騎士5. 黑心房仲的告白

<p>訂便當:</p><ul><li>排骨飯</li><li>雞腿飯</li><li>豬腳飯</li><li>燒肉飯</li></ul>

<p>新書排行榜</p><ol><li>賈伯斯傳</li><li>華頓商學院最受歡迎的談判課</li><li>洋蔥炒蛋到小英便當</li><li>吾命騎士</li><li>黑心房仲的告白</li></ol>

Page 31: 開放源碼電子書與EPUB幕後排版

語法:段落文字這是段落文字,包括**粗體**、*斜體*、***又粗又斜體***。

這是第二段落文字。

參考資料: Markdown 語法說明 http://markdown.tw/ , 電子書的定義 http://goo.gl/0pBEy

<p>這是段落文字,包括<strong>粗體</strong>、<em>斜體</em>、<strong><em>又粗又斜體</em></strong>。</p><p>這是第二段落文字。</p>

Page 32: 開放源碼電子書與EPUB幕後排版

語法:其他

![Cover](/path/to/img.jpg)

[Plurk](http://plurk.com/)

圖片

超連結

Page 33: 開放源碼電子書與EPUB幕後排版

mouapp.com

Page 34: 開放源碼電子書與EPUB幕後排版

原始碼

編譯

電子書

?eBooks

TXT, EPUB, MOBI, PDF, CHM, ...

Chapter 1. What Is EPUB 3?======================

EPUB 3 in a Nutshell-----------------------------

So what exactly is an EPUB? If you follow electronic publishing at all,

Markdown

Page 35: 開放源碼電子書與EPUB幕後排版

+

Page 36: 開放源碼電子書與EPUB幕後排版

Pandoc a universal document converter

pandoc -f markdown -t epub source.txt -o target.epub

Chapter 1. What Is EPUB 3?======================

EPUB 3 in a Nutshell-----------------------------

So what exactly is an EPUB? If you follow electronic publishing at all,

Pandoc, http://johnmacfarlane.net/pandoc/

Page 37: 開放源碼電子書與EPUB幕後排版

Pandoc a universal document converter

pandoc -f markdown -t epub source.txt -o target.epub

Pandoc, http://johnmacfarlane.net/pandoc/

pandoc -f markdown -t html source.txt -o target.html

pandoc -f markdown -t latex source.txt -o target.tex

xelatex target.tex

Page 38: 開放源碼電子書與EPUB幕後排版

幕後排版========

作者----

* 打字* 標記* 打字* 標記

電腦----

* 睡覺* 睡覺* 唉唉叫

Page 39: 開放源碼電子書與EPUB幕後排版

ePUB 幕後排版使用 Markdown

語法簡單、易讀易寫大量生產轉換其他格式讓電腦自己排版多人協作

Page 40: 開放源碼電子書與EPUB幕後排版

LeanpubPublish Early, Publish Often

http://leanpub.com/

Page 41: 開放源碼電子書與EPUB幕後排版

Book as a Service

書原始碼

題庫

電子書

投影片

講義

多人協作

出版自動化

持續更新

Service

Page 42: 開放源碼電子書與EPUB幕後排版

!

!!

plain text plain text plain text

plain text plain text plain text plain text

plain text plain text

plain text

plain tex

t plain te

xt

plain text p

lain text

ContinuousPublishing

新聞部落格

RSS日記筆記

...

Page 43: 開放源碼電子書與EPUB幕後排版

Contpub

ContinuousPublishing

contpub.org

Page 44: 開放源碼電子書與EPUB幕後排版

Contpub 註冊

http://contpub.org/

Page 45: 開放源碼電子書與EPUB幕後排版

Contpub 打字

http://contpub.org/

Page 46: 開放源碼電子書與EPUB幕後排版

Contpub 出版

http://contpub.org/

Page 48: 開放源碼電子書與EPUB幕後排版

But...

中文支援?

EPUB3?

Page 49: 開放源碼電子書與EPUB幕後排版

Open source projects

sphinx-cook

sphinx-themes

SimaQian

CaiLun

http://github.com/contpub

Page 50: 開放源碼電子書與EPUB幕後排版

The End