Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75612 - in branches/quickbook-dev/tools/quickbook: src test test/html test/html/images
From: dnljms_at_[hidden]
Date: 2011-11-22 18:44:58


Author: danieljames
Date: 2011-11-22 18:44:57 EST (Tue, 22 Nov 2011)
New Revision: 75612
URL: http://svn.boost.org/trac/boost/changeset/75612

Log:
Quickbook: Fix SVG handling.

- Fixes extension check.
- Looks for images relative to quickbook file instead of the current
  working directory, so that it will work when run from another
  directory.
- Allow user to specify the image location.
- Use `bbk_value` for synthesized attributes rather than `qbk_value`.
  It's the right thing to do, but doesn't make any practical difference.

Still not happy with image path handling. I feel that they should be
relative to the quickbook file and be rewritten - in a similar manner to
`xinclude`.
Added:
   branches/quickbook-dev/tools/quickbook/test/html/
   branches/quickbook-dev/tools/quickbook/test/html/images/
   branches/quickbook-dev/tools/quickbook/test/html/images/open_clipart_library_logo.svg (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/svg-1_1.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/svg-1_1.quickbook (contents, props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/actions.cpp | 20 ++++++++------------
   branches/quickbook-dev/tools/quickbook/src/quickbook.cpp | 12 ++++++++++++
   branches/quickbook-dev/tools/quickbook/src/quickbook.hpp | 1 +
   branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 | 1 +
   4 files changed, 22 insertions(+), 12 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.cpp 2011-11-22 18:44:57 EST (Tue, 22 Nov 2011)
@@ -758,7 +758,7 @@
             alt_pos->second.get_quickbook();
         attributes.erase("alt");
 
- if(extension == ".svg")
+ if(extension == "svg")
         {
            //
            // SVG's need special handling:
@@ -773,16 +773,14 @@
            //
 
            attributes.insert(attribute_map::value_type("format",
- qbk_value("SVG", qbk_version_n)));
+ bbk_value("SVG")));
 
            //
            // Image paths are relative to the html subdirectory:
            //
- // TODO: This seems wrong to me.
- //
            fs::path img = detail::generic_to_path(fileref);
- if(img.root_path().empty())
- img = "html" / img; // relative path
+ if (!img.has_root_directory())
+ img = quickbook::image_location / img; // relative path
 
            //
            // Now load the SVG file:
@@ -810,9 +808,8 @@
            if(a != std::string::npos)
            {
               attributes.insert(std::make_pair(
- "contentwidth", qbk_value(std::string(
- svg_text.begin() + a + 1, svg_text.begin() + b),
- qbk_version_n)
+ "contentwidth", bbk_value(std::string(
+ svg_text.begin() + a + 1, svg_text.begin() + b))
                 ));
            }
            a = svg_text.find("height");
@@ -822,9 +819,8 @@
            if(a != std::string::npos)
            {
               attributes.insert(std::make_pair(
- "contentdepth", qbk_value(std::string(
- svg_text.begin() + a + 1, svg_text.begin() + b),
- qbk_version_n)
+ "contentdepth", bbk_value(std::string(
+ svg_text.begin() + a + 1, svg_text.begin() + b))
                 ));
            }
         }

Modified: branches/quickbook-dev/tools/quickbook/src/quickbook.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/quickbook.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/quickbook.cpp 2011-11-22 18:44:57 EST (Tue, 22 Nov 2011)
@@ -50,6 +50,7 @@
     bool ms_errors = false; // output errors/warnings as if for VS
     std::vector<fs::path> include_path;
     std::vector<std::string> preset_defines;
+ fs::path image_location;
 
     static void set_macros(actions& actor)
     {
@@ -219,6 +220,7 @@
             ("ms-errors", "use Microsoft Visual Studio style error & warn message format")
             ("include-path,I", PO_VALUE< std::vector<input_string> >(), "include path")
             ("define,D", PO_VALUE< std::vector<input_string> >(), "define macro")
+ ("image-location", PO_VALUE<input_string>(), "image location")
         ;
 
         hidden.add_options()
@@ -382,6 +384,16 @@
                     xinclude_base = ".";
             }
 
+ if (vm.count("image-location"))
+ {
+ quickbook::image_location = quickbook::detail::input_to_path(
+ vm["image-location"].as<input_string>());
+ }
+ else
+ {
+ quickbook::image_location = filein.parent_path() / "html";
+ }
+
             quickbook::detail::out() << "Generating Output File: "
                 << quickbook::detail::path_to_stream(fileout)
                 << std::endl;

Modified: branches/quickbook-dev/tools/quickbook/src/quickbook.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/quickbook.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/quickbook.hpp 2011-11-22 18:44:57 EST (Tue, 22 Nov 2011)
@@ -29,6 +29,7 @@
     extern bool self_linked_headers;
     extern std::vector<fs::path> include_path;
     extern std::vector<std::string> preset_defines;
+ extern fs::path image_location;
 
     void parse_file(actions& actor,
             value include_doc_id = value(),

Modified: branches/quickbook-dev/tools/quickbook/test/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 (original)
+++ branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 2011-11-22 18:44:57 EST (Tue, 22 Nov 2011)
@@ -76,6 +76,7 @@
     [ quickbook-test section-1_5-unclosed ]
     [ quickbook-test section-1_5 ]
     [ quickbook-test simple_markup-1_5 ]
+ [ quickbook-test svg-1_1 ]
     [ quickbook-test table-1_3 ]
     [ quickbook-test table-1_5 ]
     [ quickbook-test table-1_6 ]

Added: branches/quickbook-dev/tools/quickbook/test/html/images/open_clipart_library_logo.svg
==============================================================================
Binary file. No diff available.

Added: branches/quickbook-dev/tools/quickbook/test/svg-1_1.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/svg-1_1.gold 2011-11-22 18:44:57 EST (Tue, 22 Nov 2011)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="svg_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>SVG test</title>
+ <para>
+ <inlinemediaobject><imageobject><imagedata contentdepth="513.25690" contentwidth="745.60706"
+ fileref="images/open_clipart_library_logo.svg" format="SVG"></imagedata></imageobject>
+ <textobject>
+ <phrase>open_clipart_library_logo</phrase>
+ </textobject>
+ </inlinemediaobject> <inlinemediaobject><imageobject><imagedata fileref="images/missing_image.svg"
+ format="SVG"></imagedata></imageobject>
+ <textobject>
+ <phrase>missing_image</phrase>
+ </textobject>
+ </inlinemediaobject>
+ </para>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/svg-1_1.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/svg-1_1.quickbook 2011-11-22 18:44:57 EST (Tue, 22 Nov 2011)
@@ -0,0 +1,4 @@
+[article SVG test]
+
+[$images/open_clipart_library_logo.svg]
+[$images/missing_image.svg]


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk