Forgot password?
 Create new account
View 142|Reply 3

Mathematica语法高亮

[Copy link]

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2022-7-16 01:40:49 |Read mode
建议搞一个Mathematica syntax highlighting, 参考https://github.com/halirutan/Mathematica-Source-Highlighting(This is the official Mathematica and Wolfram Language code highlighter for Mathematica.stackexchange.com and the Wolfram Community.)
freakedsmiley[1].png

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2022-8-4 01:03:28 |Read mode
hilite.me/ converts your code snippets into pretty-printed HTML format, easily embeddable into blog posts, emails and websites.

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2022-8-4 01:04:29
例如这里的API实例的Python代码高亮:
#!/usr/bin/python3
import base64
import requests


def get_screenshot(params):
    headers = {"Content-type": "application/x-www-form-urlencoded",
               "Accept": "text/plain",
               "userkey": "HQKRAKBKRARAAJBKYEIAAQ"}

    try:
        r = requests.post('https://api.site-shot.com/', headers=headers, data=params)

        if (r.status_code == requests.codes.ok):
            return r.json()
        elif (r.status_code == 404):
            print("Screenshot hasn't been generated. The error: " + r.json().error)
        elif (r.status_code == 401):
            print("Invalid authentication token")
        elif (r.status_code == 403):
            print("Active subscription hasn't been found")

    except requests.exceptions.RequestException as e:
        print('Screenshot generation has failed, the error: ' + str(e))


def main():
    screenshot = get_screenshot(
        {'url': 'https://site-shot.com/',
         'width': 1280,
         'height': 1280,
         'format': 'png',
         'response_type': 'json',
         'delay_time': 2000,
         'timeout': 60000})

    if screenshot is not None:
        base64_image = screenshot['image'].split(',', maxsplit=1)[1]
        image_file = open('screenshot.png', 'wb')
        image_file.write(base64.b64decode(base64_image))
        image_file.close()


main()

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

 Author| hbghlyj Posted at 2022-8-31 05:03:59
快速复制HTML带颜色
  1. for(child of $0.children){
  2.         child.removeAttribute("class");
  3.         child.style.color=getComputedStyle(child).getPropertyValue("color");
  4. }
Copy the Code

手机版Mobile version|Leisure Math Forum

2025-4-20 21:57 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list