haroldtreen / epub-press-clients

📦 Clients for building books with EpubPress.
https://epub.press
GNU General Public License v3.0
585 stars 69 forks source link

code block rendering error #116

Open fangyuan-neko opened 2 years ago

fangyuan-neko commented 2 years ago

I'm not fluent in English and it's my first issue, please excuse any mistakes I've made :)

I'm trying to convert GJS documentation into epub. The code block in it should be this Screenshot 2022-05-16 at 16-36-12 Asynchronous Programming GNOME JavaScript but it looks like

const {GLib} = imports.gi;
      const loop = new GLib.MainLoop(null, false);
      // Returns a Promise that randomly fails or succeeds after one second
      function unreliablePromise() {
          return new Promise((resolve, reject) => {
              GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
                  if (Math.random() >= 0.5)
                      resolve('success');
                  else
                      reject(Error('failure'));

                  return GLib.SOURCE_REMOVE;
              });
          });
      }
      // An example async function, demonstrating how Promises can be resolved
      // sequentially while catching errors in a try..catch block.
      async function exampleAsyncFunction() {
          try {
              let count = 0;

              while (true) {
                  await unreliablePromise();
                  log(`Promises resolved: ${++count}`);
              }
          } catch (e) {
              logError(e);
              loop.quit();
          }
      }
      // Run the async function
      exampleAsyncFunction();
      loop.run();

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42