Git Product home page Git Product logo

Comments (24)

mmontone avatar mmontone commented on July 17, 2024 1

I've implemented the extension in experimental folder package.

erudite-html

We should look at how to rearrange code, etc

from erudite.

mmontone avatar mmontone commented on July 17, 2024 1

That's why I need to do proper work on these method wrapping libraries. Not tests atm :)

from erudite.

mmontone avatar mmontone commented on July 17, 2024 1

I was thinking perhaps not in a different package, do it in the same package. When I say optional, I mean conditional in the code, like extensions work without darkmode stuff. But you are already using it for formulas, so then no problem. But if it can be optional, like say, for uml, let uml work without imagemagik, unless it is enabled. Not make it hard requirement, unless necessary.

from erudite.

andswitch avatar andswitch commented on July 17, 2024 1

So part of dark-mode logic is detecting if the user is running a dark theme. If the user is running a light theme, the logic will not attempt to generate or set the dark-mode image.

from erudite.

mmontone avatar mmontone commented on July 17, 2024

Maybe .. but .. how would you render a table with current Cuis text rendering capabilities?
Perhaps embedding some kind of TableMorph, I'm not sure..
About the syntax, I have not thought about it. Perhaps a way forward would be to start seriously considering the possibility of having multiple syntax extensions at once, with the MethodAdvisers approach (it doesn't occur to me an alternative method). Then you are free to implement your own Table extension parser as you please.

These are only my thoughts off the top my head.

from erudite.

mmontone avatar mmontone commented on July 17, 2024

One way, perhaps not the cleanest or most efficient, but similar to what we've doing with the other extensions, would be to integrate https://wkhtmltopdf.org.
I've tried wkhtmltoimage table.html table.png with:

<style>
  table, th, tr, td {
      border:1px solid
  }
</style>

<table>
  <tr><td>Hello</td><td>World</td>
  </table>

and works perfectly.
table

So, one idea could be to implement an HTML extension instead of table extension. This would not support Erudite syntax inside the tables, though.

from erudite.

andswitch avatar andswitch commented on July 17, 2024

Yes, that might be the easiest thing to implement for now.

When I can find the time, I'll see if I can make an extension based on MethodAdvisers and see if I can convert/combine the other extensions to/with it as well.

from erudite.

andswitch avatar andswitch commented on July 17, 2024

By the way, I noticed the following behavior in around:do::

MethodAdviserTestSubject around: #test1 do: [:receiver :nextMethod |
	Transcript show: 'Start around'.
	nextMethod value.
	Transcript show: 'End around'.
	'wrapped test1'].
MethodAdviserTestSubject around: #test1 do: [:receiver :nextMethod |
	Transcript show: 'Start around around'.
	nextMethod value.
	Transcript show: 'End around around'.
	'wrapped test1'].
MethodAdviserTestSubject new test1

Results in the following transcript output

Start around
Start around around
test1
End around around
End around
wrapped test1

Maybe my intuition for this is off, but I would have expected

Start around around
Start around
test1
End around
End around around
wrapped test1

from erudite.

mmontone avatar mmontone commented on July 17, 2024

Why do you have that intuition? That's how other method adviser libraries work?

What the around method is doing is installing a wrapping method, on top of the existing method. And so, the last method you add is the first to execute; the last you add becomes the top-level wrapping method.

from erudite.

mmontone avatar mmontone commented on July 17, 2024

Sorry, you are right, the second output should be the correct. I'll have a look. That's strange ..

from erudite.

mmontone avatar mmontone commented on July 17, 2024

Added some tests.

from erudite.

andswitch avatar andswitch commented on July 17, 2024

I've implemented the extension in experimental folder package.

erudite-html

We should look at how to rearrange code, etc

I'm working on porting formulas and plots over to EruditeExtensions. I think I'll just organize the code to match that of the HTML and UML extensions. Let me know if you prefer otherwise.

from erudite.

mmontone avatar mmontone commented on July 17, 2024

That's good. Go ahead, please.

from erudite.

andswitch avatar andswitch commented on July 17, 2024

While I'm at it, I could also enable the dark-mode functionality for HTML and UML. Should I do that? It would make the extensions more uniform, but it would also add ImageMagick as a dependency to those extensions. Also, I understand if that is considered feature creep maybe. I can also remove it entirely if you prefer... It's just nice to have if you're using a dark theme. Especially for formulas.

from erudite.

mmontone avatar mmontone commented on July 17, 2024

Is there a way of shipping that separately somehow?

from erudite.

mmontone avatar mmontone commented on July 17, 2024

Ok. Do it. We are already using lots of external applications already. But, it would be nice if you can factor it so that the behaviour is optional, all extensions work without ImageMagick installed, and if possible, do it in a separate method, like let's say #enableDarkMode, and you do dark mode stuff there. Is it possible to do it like that?

from erudite.

andswitch avatar andswitch commented on July 17, 2024

I think it should be possible to make dark mode optional.

ImageMagick is unfortunately already needed by the Formulas extension. That's because mimeTex can only generate GIF and Cuis can only read PNG, so there is call to ImageMagick to convert the GIF to PNG already when generating the formula image.

To make dark mode optional, I think it can be its own package, say EruditeExtensionsDarkMode(?) that depends on EruditeExtensions. I expect it should be possible to use MethodAdvisers also to implement this.

from erudite.

andswitch avatar andswitch commented on July 17, 2024

Alright, understood. I'll give it a shot.

from erudite.

andswitch avatar andswitch commented on July 17, 2024

So I think I'm almost there with a solution. One question about what you would prefer. I'm not sure which route to take:

  1. Turn dark-mode logic off by default. When the user turns it on, then dark-mode logic will run for DocNodes that support it (ATM: UML, HTML, Formulas, Plots) and failing to generate a dark-mode image will result in an error.
  2. Turn dark-mode logic on by default, and if the logic fails to generate a dark-mode image for whatever reason then fail silently and fallback to the original image.

These are just the ones that I could think of that make sense to me. Let me know if you have a different preference.

Note, currently it's a 'reader-side' logic. So this logic runs when the document is rendered. I felt this is more in line with i.e. dark reader extensions in the browser. But mainly it's simpler to implement as the book does not need to carry dark-mode images in the document data.

from erudite.

mmontone avatar mmontone commented on July 17, 2024

I think I would go for 2), but not turning dark-mode on by default, but detect if user is using darkmode. Possible?

from erudite.

andswitch avatar andswitch commented on July 17, 2024

Tested on Windows and Linux, please have a look

from erudite.

andswitch avatar andswitch commented on July 17, 2024

Feel free to close this issue.

from erudite.

andswitch avatar andswitch commented on July 17, 2024

Final remark: at this point you can remove EruditeMath.pck.st if you want since EruditeExtensions replaces it. Even though EruditeMath works better with the latex renderer, to be honest that part is not very interesting for me. So feel free to remove EruditeMath.

from erudite.

mmontone avatar mmontone commented on July 17, 2024

Ok. I'm not sure what to do with old vs new extensions yet ...

from erudite.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.