4
$\begingroup$

I have found an html page clearly created using the Save as HTML option of Mathematica. Is there a way to reverse this operation? That is open the html file with Mathematica and render it as a nb file again?

$\endgroup$
7
  • 2
    $\begingroup$ Without proper specification via Export, by default almost everything important is rasterized so I don't think so. Why not embedded CDF? $\endgroup$
    – Kuba
    Commented Dec 9, 2013 at 11:26
  • $\begingroup$ @Kuba ok, I didn't realize that not only images but also expression were rasterized. What is "embedded CDF"? (I am not the author of the html page) $\endgroup$
    – Red
    Commented Dec 9, 2013 at 12:35
  • $\begingroup$ CDF. Usually there are links to source notebooks but if there isn't any maybe you can ask the author? I don't believe text recognition approach will be successful with Mathematica syntax. $\endgroup$
    – Kuba
    Commented Dec 9, 2013 at 12:40
  • $\begingroup$ @Kuba I don't think he created the webpage himself, he probably wants to run something he found online. Red, is this correct? I've felt the pain of that before, uncopyable rasterized cells are very annoying. $\endgroup$
    – Szabolcs
    Commented Dec 9, 2013 at 19:57
  • $\begingroup$ @Szabolcs You are right, but I know it, have you read all the comments? :) $\endgroup$
    – Kuba
    Commented Dec 9, 2013 at 20:00

1 Answer 1

5
$\begingroup$

I've created test image with Heike's code from How to create word clouds? and I've posted it... here :):

enter image description here

So let's download it:

pic = Import["https://i.sstatic.net/Ni4Kl.png"]; 

In case of full html you can use Import[....html, "Images"].

TextRecognize[ImageResize[pic, {Automatic, 1100}]]

enter image description here

Not perfect but it's something. It is String so after corrections you can convert it to InputForm.

You can also play with ImageResize, I've choosen 1100 because it gives nice output.

I think that the first operation should be

StringReplace[..., {"»?" -> "#", "f?" -> "#", " . " -> "."}]

:)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.