Re: [O] Scaling HTML-exported SVG

2016-07-24 Thread Christian Moe

Jarmo Hurri writes:

> The method you suggested above - setting id - works (all tests done in
> Chrome).

Mine are in Firefox. 

> But setting id-values is cumbersome, because you need to do it
> for every file.
> It is also possible to set a CSS class similarly, that is, modifying
> your example above,
>
> #+html_head_extra: .svgfig {width: 200px; }
>
> #+attr_html: :class svgfig
> [[path/to/image.svg]]
>
> This also works and is better, because then it is possible to set a
> common class for all SVG figures, and handle them with a single CSS
> rule.

Sure, if they should mostly be scaled to the same size. I just didn't
make that assumption.

> Better, but not yet perfect, because I still need to add a
> attr_html to every SVG figure.

> But there seems to be a way around this. With the last approach the
> generated HTML looks something like
>
> 

Indeed. Now I'm confused, because this example seems to mean I got
several things wrong earlier today. First, it seems one *can* scale an
SVG image by setting attributes on the  element, not just by
scaling the container element as I thought. At least in FF and
Chrome. And second, Org passes attributes from #+attr_html to the
 element, not to the container  as I wrote, though I could
have sworn that was what I saw when I tested today. On that note, I
think I'll go to bed... But first:

> Why don't we just set a common class for all SVG-images in an HTML
> export by default? Then we could still use an  to embed it, and
> control its size from CSS.

> It seems to me that this solves the problem, and requires an extremely
> small change.

Me too. At least, I cannot think of any obvious disadvantages, and it
could be helpful if you want all or most of your SVGs to be scaled to
the same size (or otherwise styled the same way). Particularly if you
need to distinguish them from  tags embedding other media, like
videos.

(If you're *not* using  for anything beside SVGs, or at least
not in  environments, you could just style objects,
couldn't you?  e.g.:

  object { width: 200px; }

or slightly safer

  .figure object { width: 200px; }

But I agree that an explicit 'svg' class could be better.)

Yours,
Christian




Re: [O] Scaling HTML-exported SVG

2016-07-24 Thread Jarmo Hurri
Jarmo Hurri  writes:

> Christian Moe  writes:
>>   #+html_head_extra: #svgfig {width: 200px; }
>>
>>   #+attr_html: :id svgfig
>>   [[path/to/image.svg]]
>>
>> For this to work, the SVG needs to be written to be scalable (with
>> viewport set etc.).
>
> (Also addressed this in the other thread; also here for completeness.)
>
> But this means scaling on a file-by-file basis, which is very
> inconvenient for any larger projects.

Did some tests.

The method you suggested above - setting id - works (all tests done in
Chrome). But setting id-values is cumbersome, because you need to do it
for every file.

It is also possible to set a CSS class similarly, that is, modifying
your example above,

#+html_head_extra: .svgfig {width: 200px; }

#+attr_html: :class svgfig
[[path/to/image.svg]]

This also works and is better, because then it is possible to set a
common class for all SVG figures, and handle them with a single CSS
rule. Better, but not yet perfect, because I still need to add a
attr_html to every SVG figure.

But there seems to be a way around this. With the last approach the
generated HTML looks something like



Why don't we just set a common class for all SVG-images in an HTML
export by default? Then we could still use an  to embed it, and
control its size from CSS.

It seems to me that this solves the problem, and requires an extremely
small change.

Jarmo




Re: [O] Scaling HTML-exported SVG

2016-07-24 Thread Jarmo Hurri
Christian Moe  writes:

> Jarmo Hurri writes:
>> Does anyone have any idea of how to scale an SVG figure produced by Org
>> (Asymptote)? The exported HTML is
>>
>> 
>> 
>> Sorry, your browser does not support SVG.
>> 
>> 
>
> You can scale the SVG by scaling the  element's container,
> i.e. the  with class "figure". Setting attributes on the image
> link with #+attr_html as usual should work, because they are passed to
> the figure container rather than to the .
>
> Either:
>
>   #+attr_html: :width 200px
>   [[path/to/image.svg]]
>
>
> or:
>
>   #+html_head_extra: #svgfig {width: 200px; }
>
>   #+attr_html: :id svgfig
>   [[path/to/image.svg]]
>
> For this to work, the SVG needs to be written to be scalable (with
> viewport set etc.).

(Also addressed this in the other thread; also here for completeness.)

But this means scaling on a file-by-file basis, which is very
inconvenient for any larger projects.

Jarmo




Re: [O] Scaling HTML-exported SVG

2016-07-24 Thread Christian Moe



Jarmo Hurri writes:

> Greetings.
>
> Does anyone have any idea of how to scale an SVG figure produced by Org
> (Asymptote)? The exported HTML is
>
> 
> 
> Sorry, your browser does not support SVG.
> 
> 

(Suggested an answer on another thread. For completeness:)

You can scale the SVG by scaling the  element's container,
i.e. the  with class "figure". Setting attributes on the image link
with #+attr_html as usual should work, because they are passed to the
figure container rather than to the .

Either:

  #+attr_html: :width 200px
  [[path/to/image.svg]]


or:

  #+html_head_extra: #svgfig {width: 200px; }

  #+attr_html: :id svgfig
  [[path/to/image.svg]]

For this to work, the SVG needs to be written to be scalable (with
viewport set etc.).

Yours,
Christian



[O] Scaling HTML-exported SVG

2016-07-22 Thread Jarmo Hurri

Greetings.

Does anyone have any idea of how to scale an SVG figure produced by Org
(Asymptote)? The exported HTML is



Sorry, your browser does not support SVG.



and the SVG file begins with





I have tried various approaches in my CSS, but nothing has worked so
far. I have searched online, and scaling SVG files seems to be a mess.

I basically want to scale the SVG file to be, say 80% of viewed
width. My first try was

.figure
{
width: 80vw;
}


After that I have tried maybe 120 other versions, and nothing has worked.

Jarmo