Lynx
  • 简体中文
  • 文档编程语言验证

    对于文档中中的编程语言,补齐独立的引用展示,保证在 doc 文档中通过组件使用时可以支持正常语法高亮等。

    验证

    Swift

    import Markdown
    
    let markdownText = "# Hello, Swift Markdown!\nThis is a sample paragraph."
    do {
        let document = try Document(parsing: markdownText)
        document.children.forEach { element in
            print(element)
        }
    } catch {
        print("Failed to parse Markdown: \(error)")
    }

    Objective-C

    #import <Foundation/Foundation.h>
    
    #import "DemoLynxTemplateProvider.h"
    
    @implementation DemoLynxProvider
    
    - (void)loadTemplateWithUrl:(NSString*)url onComplete:(LynxTemplateLoadBlock)callback {
      // your logic for fetching resources.
      if (!url || [url length] == 0) {
        NSError *urlError = [NSError errorWithDomain:@"com.lynx"
                                                code:400
                                            userInfo:@{NSLocalizedDescriptionKey : @"Invalid URL."}];
        callback(nil, urlError);
        return;
      }
    
      NSURL *urlObject = [NSURL URLWithString:url];
      if (!urlObject) {
        NSError *urlParseError =
            [NSError errorWithDomain:@"com.lynx"
                                code:401
                            userInfo:@{NSLocalizedDescriptionKey : @"Malformed URL."}];
        callback(nil, urlParseError);
        return;
      }
    
      NSURLSession *session = [NSURLSession sharedSession];
      NSURLSessionDataTask *dataTask = [session
            dataTaskWithURL:urlObject
          completionHandler:^(NSData *_Nullable data, NSURLResponse *_Nullable response,
                              NSError *_Nullable error) {
            if (error) {
              NSError *downloadError =
                  [NSError errorWithDomain:@"com.lynx"
                                      code:error.code
                                  userInfo:@{NSLocalizedDescriptionKey : error.localizedDescription}];
              callback(nil, downloadError);
              return;
            }
    
            if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
              NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
              if (httpResponse.statusCode != 200) {
                NSError *httpError = [NSError
                    errorWithDomain:@"com.lynx"
                               code:httpResponse.statusCode
                           userInfo:@{
                             NSLocalizedDescriptionKey : [NSString
                                 stringWithFormat:@"HTTP Error: %ld", (long)httpResponse.statusCode]
                           }];
                callback(nil, httpError);
                return;
              }
            }
    
            if (!data || data.length == 0) {
              NSError *emptyDataError =
                  [NSError errorWithDomain:@"com.lynx"
                                      code:402
                                  userInfo:@{NSLocalizedDescriptionKey : @"Downloaded data is empty."}];
              callback(nil, emptyDataError);
              return;
            }
    
            callback(data, nil);
          }];
    
      [dataTask resume];
    }
    
    @end
    

    Kotlin

    fun main() {
      println("Hello, World!")
    }

    ruby

    Podfile
    source 'https://cdn.cocoapods.org/'
    
    platform :ios, '10.0'
    
    target 'YourTarget' do
      pod 'Lynx', '4.0.0', :subspecs => [
        'Framework',
      ]
    
      pod 'PrimJS', '4.0.0', :subspecs => ['quickjs', 'napi']
    end

    groovy

    build.gradle
    dependencies {
        // lynx dependencies
        implementation "org.lynxsdk.lynx:lynx:4.0.0"
        implementation "org.lynxsdk.lynx:lynx-jssdk:4.0.0"
        implementation "org.lynxsdk.lynx:lynx-trace:4.0.0"
        implementation "org.lynxsdk.lynx:primjs:4.0.0"
    }
    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。