jeaye / stdman

Formatted C++20 stdlib man pages (cppreference)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

equations in docs

robgal519 opened this issue · comments

When I opened man page for std::normal_distribution I found out that the equation is not displayed correctly.
It looks like this:
f(x; μ,σ) =

              1
              σ
              √
              2π

              exp⎛
              ⎜
              ⎝

              -1
              2

              ⎛
              ⎜
              ⎝

              x-μ
              σ

              ⎞
              ⎟
              ⎠2
              ⎞
              ⎟
              ⎠

and it should be all in one line.

commented

This is a bug in elinks, which is an independent program, we spawn subprocess to run elinks and render the HTML pages.

The lastest update for elinks is 2012-10-30, so I would not expect them to fix it.

commented

@jeaye Could you please review this issue?

I've recently been thinking about trying out https://www.brow.sh/ instead of elinks. It should offer much better rendering, since it just uses a headless Firefox. The only question would be around rendering a full frame to a string and pulling out the content we need. If you're looking for something to dig into, that would be a huge step for stdman's formatting.

commented

@jeaye
Thanks for your guide, I have tried with Browsh, but it can't rend the equation correctly, though it's much better than Elinks

img

commented

I have also tested Browsh for this page:
https://en.cppreference.com/w/cpp/string/basic_string

For the Helper classes section, Browsh rend it as:

 Helper classes                                                                                
        std::hash         (C++11)                                                        
        std::hash       (C++20)                                                        
        std::hash      (C++11)                                                        
        std::hash      (C++11)                                                        
        std::hash        (C++11) hash support for strings                               
        std::hash    (C++20) (class template specialization)                        
        std::hash  (C++20)                                                        
        std::hash (C++20)                                                        
        std::hash (C++20)                                                        
        std::hash   (C++20)   

Which is still not perfect.

For elinks, it generates:

Helper classes                                                                                                                                                            
          std::hash<std::string>                                                                                                                                          
          std::hash<std::u8string>                                                                                                                                        
          std::hash<std::u16string>                                                                                                                                       
          std::hash<std::u32string>                                                                                                                                       
          std::hash<std::wstring>                                                                                                                                         
          std::hash<std::pmr::string>                                                                                                                                     
          std::hash<std::pmr::u8string>                                                                                                                                   
          std::hash<std::pmr::u16string>                                                                                                                                  
          std::hash<std::pmr::u32string>                                                                                                                                  
          std::hash<std::pmr::wstring>   hash support for strings                                                                                                         
          (C++11)                        (class template specialization)                                                                                                  
          (C++20)
          (C++11)                                                                                                                                                         
          (C++11)                                                                                                                                                         
          (C++11)                                                                                                                                                         
          (C++20)                                                                                                                                                         
          (C++20)                                                                                                                                                         
          (C++20)                                                                                                                                                         
          (C++20)                                                                                                                                                         
          (C++20)        

Browsh looks better, but still not ideal.
Of course, this may also be due to the cpprefencen template itself has some problems, I can not copy this paragraph in its original style. When I copy the table and paste, we get the text in mess:

std::hash<std::string>std::hash<std::u8string>std::hash<std::u16string>std::hash<std::u32string>std::hash<std::wstring>std::hash<std::pmr::string>std::hash<std::pmr::u8string>std::hash<std::pmr::u16string>std::hash<std::pmr::u32string>std::hash<std::pmr::wstring>(C++11)(C++20)(C++11)(C++11)(C++11)(C++20)(C++20)(C++20)(C++20)(C++20) | hash support for strings(class
-- | --

Thanks so much for testing this. It does seem like cppref may be the issue for the the last bit. Copy/paste is always a good test for how things will render in text.

Outside of that, though, browsh does a much nicer job than elinks. Do you see any potential issues in stdman using browsh for generation instead? The only thing I noticed is that browsh is rendering ads; I wonder if we can configure it to use uBlock Origin. If not, we can just cut out that bit of the HTML.

commented

I will make a proposal later, I need to go through the current source code of stdman