fixes for epub validation re issue #4
This commit is contained in:
parent
52c8768ac2
commit
dbfd02ff96
|
@ -27,6 +27,8 @@
|
||||||
string tempdir = null;
|
string tempdir = null;
|
||||||
string format = null;
|
string format = null;
|
||||||
string author = null;
|
string author = null;
|
||||||
|
string bookid = null;
|
||||||
|
string language = "en";
|
||||||
string images = null;
|
string images = null;
|
||||||
var debug = false;
|
var debug = false;
|
||||||
|
|
||||||
|
@ -59,6 +61,12 @@
|
||||||
case "--author":
|
case "--author":
|
||||||
author = args[i + 1];
|
author = args[i + 1];
|
||||||
break;
|
break;
|
||||||
|
case "--bookid":
|
||||||
|
bookid = args[i + 1];
|
||||||
|
break;
|
||||||
|
case "--language":
|
||||||
|
language = args[i + 1];
|
||||||
|
break;
|
||||||
case "--images":
|
case "--images":
|
||||||
images = args[i + 1];
|
images = args[i + 1];
|
||||||
break;
|
break;
|
||||||
|
@ -140,7 +148,7 @@
|
||||||
{
|
{
|
||||||
case "html":
|
case "html":
|
||||||
Directory.CreateDirectory(output);
|
Directory.CreateDirectory(output);
|
||||||
rend = new HtmlRenderer();
|
rend = new HtmlRenderer(language);
|
||||||
break;
|
break;
|
||||||
case "epub":
|
case "epub":
|
||||||
if (string.IsNullOrWhiteSpace(author))
|
if (string.IsNullOrWhiteSpace(author))
|
||||||
|
@ -148,7 +156,7 @@
|
||||||
Console.WriteLine(@"Epub format requires the --author argument.");
|
Console.WriteLine(@"Epub format requires the --author argument.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
rend = new EpubRenderer(author);
|
rend = new EpubRenderer(author, bookid, language);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ShowHelp();
|
ShowHelp();
|
||||||
|
@ -183,6 +191,8 @@
|
||||||
[--template ""/path/to/template/dir""]
|
[--template ""/path/to/template/dir""]
|
||||||
[--images ""/path/to/images/dir""]
|
[--images ""/path/to/images/dir""]
|
||||||
[--author ""Author Name""]
|
[--author ""Author Name""]
|
||||||
|
[--bookid ""ePub Book ID""]
|
||||||
|
[--language ""language""]
|
||||||
[--debug]");
|
[--debug]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
{
|
{
|
||||||
File.Delete(file);
|
File.Delete(file);
|
||||||
}
|
}
|
||||||
var rend = new HtmlRenderer();
|
var rend = new HtmlRenderer("en");
|
||||||
rend.Render(story, path, true);
|
rend.Render(story, path, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,10 +90,14 @@
|
||||||
public class EpubRenderer : HtmlRenderer
|
public class EpubRenderer : HtmlRenderer
|
||||||
{
|
{
|
||||||
private readonly string _author;
|
private readonly string _author;
|
||||||
|
private readonly string _bookId;
|
||||||
|
private readonly string _language;
|
||||||
|
|
||||||
public EpubRenderer(string author) : base()
|
public EpubRenderer(string author, string bookId, string language) : base(language)
|
||||||
{
|
{
|
||||||
_author = author;
|
_author = author;
|
||||||
|
_bookId = bookId ?? Guid.NewGuid().ToString("D");
|
||||||
|
_language = language ?? "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(Model.Parser.ResolvedStory story, string outPath, bool debug = false)
|
public override void Render(Model.Parser.ResolvedStory story, string outPath, bool debug = false)
|
||||||
|
@ -113,6 +117,8 @@
|
||||||
select new Chapter(Path.Combine(temppath, fname), fname, fname.Replace(".html", string.Empty)));
|
select new Chapter(Path.Combine(temppath, fname), fname, fname.Replace(".html", string.Empty)));
|
||||||
|
|
||||||
var epub = new Epub(Story.Name, _author, chapters);
|
var epub = new Epub(Story.Name, _author, chapters);
|
||||||
|
epub.BookId = _bookId;
|
||||||
|
epub.Language = _language;
|
||||||
epub.AddResourceFile(new ResourceFile("styles.css", Path.Combine(temppath, "styles.css"), "text/css"));
|
epub.AddResourceFile(new ResourceFile("styles.css", Path.Combine(temppath, "styles.css"), "text/css"));
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(ImageDir))
|
if (!string.IsNullOrWhiteSpace(ImageDir))
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
public class HtmlRenderer : IRenderer
|
public class HtmlRenderer : IRenderer
|
||||||
{
|
{
|
||||||
|
private readonly string _language;
|
||||||
|
|
||||||
protected readonly Markdown Markdown;
|
protected readonly Markdown Markdown;
|
||||||
|
|
||||||
public string IndexTemplate { get; set; }
|
public string IndexTemplate { get; set; }
|
||||||
|
@ -18,8 +20,9 @@
|
||||||
|
|
||||||
protected ResolvedStory Story { get; set; }
|
protected ResolvedStory Story { get; set; }
|
||||||
|
|
||||||
public HtmlRenderer()
|
public HtmlRenderer(string language)
|
||||||
{
|
{
|
||||||
|
_language = language;
|
||||||
Markdown = new Markdown();
|
Markdown = new Markdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +42,7 @@
|
||||||
{
|
{
|
||||||
var index = FillTemplate(IndexTemplate ?? Template.Index, new Dictionary<string, string>
|
var index = FillTemplate(IndexTemplate ?? Template.Index, new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
|
{"Language", _language},
|
||||||
{"Title", story.Name},
|
{"Title", story.Name},
|
||||||
{"Description", Markdown.Transform(story.Description)},
|
{"Description", Markdown.Transform(story.Description)},
|
||||||
{"FirstScene", string.Format("{0}.html", story.FirstPage)}
|
{"FirstScene", string.Format("{0}.html", story.FirstPage)}
|
||||||
|
@ -64,6 +68,7 @@
|
||||||
|
|
||||||
var scene = FillTemplate(SceneTemplate ?? Template.Scene, new Dictionary<string, string>
|
var scene = FillTemplate(SceneTemplate ?? Template.Scene, new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
|
{"Language", _language},
|
||||||
{"Title", story.Name},
|
{"Title", story.Name},
|
||||||
{"Content", Markdown.Transform(content)}
|
{"Content", Markdown.Transform(content)}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
|
||||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
<html lang="@Language" xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<title>@Title</title>
|
<title>@Title</title>
|
||||||
<link rel="stylesheet" type="text/css" href="styles.css"/>
|
<link rel="stylesheet" type="text/css" href="styles.css"/>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
|
|
||||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
<html lang="@Language" xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<title>@Title</title>
|
<title>@Title</title>
|
||||||
<link rel="stylesheet" type="text/css" href="styles.css" />
|
<link rel="stylesheet" type="text/css" href="styles.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Reference in New Issue