Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code block rendering error #116

Open
fangyuan-neko opened this issue May 16, 2022 · 0 comments
Open

code block rendering error #116

fangyuan-neko opened this issue May 16, 2022 · 0 comments

Comments

@fangyuan-neko
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant