text:
title: "Web: Set up a Blog with Github Pages"
header:
  image: /assets/images/unsplash-image-1.jpg
  caption: "Photo credit: [**Unsplash**](https://unsplash.com)"
categories:
  - Programming
tags:
  - Web
featurePicture: "/assetsLucas/images/2017-01-24-prog-set-up-a-blog-with-github-pages-featurePicture.jpg"
excerpt: Why use Github Pages? How does it work? How to start?  How to write a blog? Some other note?
---
# Set up a Blog with Github Pages

## Why use Github Pages

* Free
* Easy to install (No server or ssl cert needed)
* Static Page (Fast)

## How does it work

1. First of all, Github let you to create a static website for you and also your projects, i.e. Github Pages.

2. Github Pages has an embedded web engine called `JekyII` to let you build your blog on Github Pages.

3. What does `JekyII` do or support:

	* Provide you a convient architecture to manage your sites, for example, you can set mostly all the site param in 1 `.yaml` file.
	* Act as an server to serve your site.
	* Support `Liquid` web template, i.e. load and pass parameter to the template.
	* Render your blog content based on `Markdown` syntax.
	* Support theme so possible to build an elagant webpage quickly.

## How to start

###### Simply follow the tutorial: [Minimal Mistakes](https://mmistakes.github.io/minimal-mistakes/docs/quick-start-guide/)

> ##### Tips for you:
> Just simply fork or clone the preoject [mmistakes/minimal-mistakes](https://github.com/mmistakes/minimal-mistakes). Although it is a theme, it has evrything to set up your site.

## How to write a blog

`There is no embedded text editor like WordPress, but you don't need to learn or write the html code.`

###### To blog, you need to use `Markdown` syntax, which can be mastered within 5 minutes, here are some resource:

* [A simple guide by Github](https://guides.github.com/features/mastering-markdown/)
* [A simple cheatsheet table](http://commonmark.org/help/)
* [Master Google](https://www.google.com)

###### Once You have a basic idea, you can play an write in the online editor [**Github Markdown Editor**](https://jbt.github.io/markdown-editor).

## Some other note

##### Development
>[A better jeckyII doc](http://www.rubydoc.info/github/mojombo/jekyll/)
>
>Page and post share the same structure i.e. yaml meta data +  content
>
>A web page = layout + _post / (_page + _include file)
>
>If the extension is. md, the content can have a markdwon processing.

##### Navi Bar
>To edit the navi bar, go to /_data/navigation.yml

##### Demo Site
>/docs is another deploy directory, you can use it to build a demo site.

##### Analytics Provider
>To enable google analytics, simply input the track id in `_config.yml` when using Minimal Mistakes


text:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE bulletml SYSTEM "bulletml.dtd">
<bulletml>
  <action label="top">
    <accel>
      <horizontal type="absolute">10</horizontal>
      <term>0</term>
    </accel>
  </action>
</bulletml>

redpajama_set_name: RedPajamaGithub


text:
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;

namespace Api.Web.Extensions
{
    public class CustomMessageResult : IHttpActionResult
    {
        public string Message { get; set; }
        private HttpStatusCode status = HttpStatusCode.InternalServerError;
        public HttpRequestMessage requestMessage;

        public CustomMessageResult()
        {

        }
        public CustomMessageResult(string message,HttpStatusCode statusCode = HttpStatusCode.InternalServerError)
        {
            this.Message = message;
            status = statusCode;
        }

        public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
        {
            var response = new HttpResponseMessage(status);
            response.Content = new StringContent(Message);
            response.RequestMessage = requestMessage;
            return Task.FromResult(response);
        }
    }
}


text:
import socket

class FriggWorkerBaseError(Exception):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.host = socket.getfqdn()

class ApiError(FriggWorkerBaseError):
    def __init__(self, error):
        self.code = error['code']
        super().__init__(error['message'])

class GitCloneError(FriggWorkerBaseError):
    MESSAGES = {
        'MISSING_BRANCH': 'Branch does not exist',
        'MISSING_COMMIT': 'Commit does not exist',
        'DNS': 'Can not resolve host',
        'EMPTY_REPLY': 'Empty reply from vcs server',
        'UNKNOWN': 'Unknown error cloning',
    }

    def __init__(self, type, stdout, stderr, report_build_as_error, worker_should_quit=False):
        self.type = type
        self.stdout = stdout
        self.stderr = stderr
        self.report_build_as_error = report_build_as_error
        self.worker_should_quit = worker_should_quit
        super().__init__(self.MESSAGES[type])


text:
import winbrewtest
import winbrew.execute

class MockArgs(object):
    force = False

class InstallPlanTest(winbrewtest.TestCase):

    def test_dependencies(self):
        formula = winbrew.Formula.formula_by_name('sfml')()
        plan = winbrew.execute.InstallPlan([formula], MockArgs())
        plan = [p.name for p in plan]
        assert(plan == ['cmake', 'sfml'])

    def test_multiple(self):
        formula = [winbrew.Formula.formula_by_name(n)() for n in ('openssl','sfml')]
        plan = winbrew.execute.InstallPlan(formula, MockArgs())
        plan = [p.name for p in plan]
        assert(plan == ['perl', 'openssl', 'cmake', 'sfml'])


text:
require 'spec_helper'

require 'puppet/interface'

class ActionManagerTester
  include Puppet::Interface::ActionManager
end

describe Puppet::Interface::ActionManager do
  subject { ActionManagerTester.new }

  describe "when included in a class" do
    it "should be able to define an action" do
      subject.action(:foo) do
        when_invoked { |options| "something "}
      end
    end

    it "should be able to define a 'script' style action" do
      subject.script :bar do |options|
        "a bar is where beer is found"
      end
    end

    it "should be able to list defined actions" do
      subject.action(:foo) do
        when_invoked { |options| "something" }
      end
      subject.action(:bar) do
        when_invoked { |options| "something" }
      end

      subject.actions.should =~ [:foo, :bar]
    end

    it "should list 'script' actions" do
      subject.script :foo do |options| "foo" end
      subject.actions.should =~ [:foo]
    end

    it "should list both script and normal actions" do
      subject.action :foo do
        when_invoked do |options| "foo" end
      end
      subject.script :bar do |options| "a bar is where beer is found" end

      subject.actions.should =~ [:foo, :bar]
    end

    it "should be able to indicate when an action is defined" do
      subject.action(:foo) do
        when_invoked { |options| "something" }
      end

      subject.should be_action(:foo)
    end

    it "should indicate an action is defined for script actions" do
      subject.script :foo do |options| "foo" end
      subject.should be_action :foo
    end

    it "should correctly treat action names specified as strings" do
      subject.action(:foo) do
        when_invoked { |options| "something" }
      end

      subject.should be_action("foo")
    end
  end

  describe "when used to extend a class" do
    subject { Class.new.extend(Puppet::Interface::ActionManager) }

    it "should be able to define an action" do
      subject.action(:foo) do
        when_invoked { |options| "something "}
      end
    end

    it "should be able to list defined actions" do
      subject.action(:foo) do
        when_invoked { |options| "something" }
      end
      subject.action(:bar) do
        when_invoked { |options| "something" }
      end

      subject.actions.should include(:bar)
      subject.actions.should include(:foo)
    end

    it "should be able to indicate when an action is defined" do
      subject.action(:foo) { when_invoked do |options| true end }
      subject.should be_action(:foo)
    end
  end

  describe "when used both at the class and instance level" do
    before do
      @klass = Class.new do
        include Puppet::Interface::ActionManager
        extend Puppet::Interface::ActionManager
        def __invoke_decorations(*args) true end
        def options() [] end
      end
      @instance = @klass.new
    end

    it "should be able to define an action at the class level" do
      @klass.action(:foo) do
        when_invoked { |options| "something "}
      end
    end

    it "should create an instance method when an action is defined at the class level" do
      @klass.action(:foo) do
        when_invoked { |options| "something" }
      end
      @instance.foo.should == "something"
    end

    it "should be able to define an action at the instance level" do
      @instance.action(:foo) do
        when_invoked { |options| "something "}
      end
    end

    it "should create an instance method when an action is defined at the instance level" do
      @instance.action(:foo) do
        when_invoked { |options| "something" }
      end
      @instance.foo.should == "something"
    end

    it "should be able to list actions defined at the class level" do
      @klass.action(:foo) do
        when_invoked { |options| "something" }
      end
      @klass.action(:bar) do
        when_invoked { |options| "something" }
      end

      @klass.actions.should include(:bar)
      @klass.actions.should include(:foo)
    end

    it "should be able to list actions defined at the instance level" do
      @instance.action(:foo) do
        when_invoked { |options| "something" }
      end
      @instance.action(:bar) do
        when_invoked { |options| "something" }
      end

      @instance.actions.should include(:bar)
      @instance.actions.should include(:foo)
    end

    it "should be able to list actions defined at both instance and class level" do
      @klass.action(:foo) do
        when_invoked { |options| "something" }
      end
      @instance.action(:bar) do
        when_invoked { |options| "something" }
      end

      @instance.actions.should include(:bar)
      @instance.actions.should include(:foo)
    end

    it "should be able to indicate when an action is defined at the class level" do
      @klass.action(:foo) do
        when_invoked { |options| "something" }
      end
      @instance.should be_action(:foo)
    end

    it "should be able to indicate when an action is defined at the instance level" do
      @klass.action(:foo) do
        when_invoked { |options| "something" }
      end
      @instance.should be_action(:foo)
    end

    context "with actions defined in superclass" do
      before :each do
        @subclass = Class.new(@klass)
        @instance = @subclass.new

        @klass.action(:parent) do
          when_invoked { |options| "a" }
        end
        @subclass.action(:sub) do
          when_invoked { |options| "a" }
        end
        @instance.action(:instance) do
          when_invoked { |options| "a" }
        end
      end

      it "should list actions defined in superclasses" do
        @instance.should be_action(:parent)
        @instance.should be_action(:sub)
        @instance.should be_action(:instance)
      end

      it "should list inherited actions" do
        @instance.actions.should =~ [:instance, :parent, :sub]
      end

      it "should not duplicate instance actions after fetching them (#7699)" do
        @instance.actions.should =~ [:instance, :parent, :sub]
        @instance.get_action(:instance)
        @instance.actions.should =~ [:instance, :parent, :sub]
      end

      it "should not duplicate subclass actions after fetching them (#7699)" do
        @instance.actions.should =~ [:instance, :parent, :sub]
        @instance.get_action(:sub)
        @instance.actions.should =~ [:instance, :parent, :sub]
      end

      it "should not duplicate superclass actions after fetching them (#7699)" do
        @instance.actions.should =~ [:instance, :parent, :sub]
        @instance.get_action(:parent)
        @instance.actions.should =~ [:instance, :parent, :sub]
      end
    end

    it "should create an instance method when an action is defined in a superclass" do
      @subclass = Class.new(@klass)
      @instance = @subclass.new

      @klass.action(:foo) do
        when_invoked { |options| "something" }
      end
      @instance.foo.should == "something"
    end
  end

  describe "#action" do
    it 'should add an action' do
      subject.action(:foo) { when_invoked do |options| true end }
      subject.get_action(:foo).should be_a Puppet::Interface::Action
    end

    it 'should support default actions' do
      subject.action(:foo) { when_invoked do |options| true end; default }
      subject.get_default_action.should == subject.get_action(:foo)
    end

    it 'should not support more than one default action' do
      subject.action(:foo) { when_invoked do |options| true end; default }
      expect { subject.action(:bar) {
          when_invoked do |options| true end
          default
        }
      }.to raise_error /cannot both be default/
    end
  end

  describe "#get_action" do
    let :parent_class do
      parent_class = Class.new(Puppet::Interface)
      parent_class.action(:foo) { when_invoked do |options| true end }
      parent_class
    end

    it "should check that we can find inherited actions when we are a class" do
      Class.new(parent_class).get_action(:foo).name.should == :foo
    end

    it "should check that we can find inherited actions when we are an instance" do
      instance = parent_class.new(:foo, '0.0.0')
      instance.get_action(:foo).name.should == :foo
    end
  end
end


text:
BOARD ?= qemu_x86
MDEF_FILE = prj.mdef
KERNEL_TYPE = micro
CONF_FILE = prj_$(ARCH).conf
SOURCE_DIR = $(ZEPHYR_BASE)/samples/crypto/test_prng/

include $(ZEPHYR_BASE)/Makefile.inc


text:
package infinite

import (
	"gopkg.in/Clever/optimus.v3"
)

type infiniteTable struct {
	rows    chan optimus.Row
	stopped bool
}

func (i infiniteTable) Rows() <-chan optimus.Row {
	return i.rows
}

func (i infiniteTable) Err() error {
	return nil
}

func (i *infiniteTable) Stop() {
	i.stopped = true
}

func (i *infiniteTable) start() {
	defer i.Stop()
	defer close(i.rows)
	for {
		if i.stopped {
			break
		}
		i.rows <- map[string]interface{}{}
	}
}

// New creates a new Table that infinitely sends empty rows.
func New() optimus.Table {
	table := &infiniteTable{rows: make(chan optimus.Row)}
	go table.start()
	return table
}


text:
using System;
using System.Runtime.InteropServices;

namespace Examples
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application = null;
            SolidEdgeAssembly.AssemblyDocument assemblyDocument = null;
            SolidEdgeAssembly.Relations3d relations3d = null;
            SolidEdgeAssembly.AngularRelation3d angularRelation3d = null;

            try
            {
                // See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
                OleMessageFilter.Register();

                // Attempt to connect to a running instance of Solid Edge.
                application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
                assemblyDocument = application.ActiveDocument as SolidEdgeAssembly.AssemblyDocument;

                if (assemblyDocument != null)
                {
                    relations3d = assemblyDocument.Relations3d;

                    for (int i = 1; i <= relations3d.Count; i++)
                    {
                        angularRelation3d = relations3d.Item(i) as SolidEdgeAssembly.AngularRelation3d;

                        if (angularRelation3d != null)
                        {
                            int GeometryType;
                            double PointX;
                            double PointY;
                            double PointZ;
                            double VectorX;
                            double VectorY;
                            double VectorZ;

                            angularRelation3d.GetGeometry1(out GeometryType, out PointX, out PointY, out PointZ, out VectorX, out VectorY, out VectorZ);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                OleMessageFilter.Unregister();
            }
        }
    }
}


text:
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/quic/test_tools/quic_test_packet_maker.h"

#include <list>
#include <utility>

#include "base/memory/ptr_util.h"
#include "net/quic/core/quic_framer.h"
#include "net/quic/core/quic_http_utils.h"
#include "net/quic/core/quic_utils.h"
#include "net/quic/test_tools/quic_test_utils.h"

using std::make_pair;

namespace net {
namespace test {

QuicTestPacketMaker::QuicTestPacketMaker(QuicVersion version,
                                         QuicConnectionId connection_id,
                                         MockClock* clock,
                                         const std::string& host,
                                         Perspective perspective)
    : version_(version),
      connection_id_(connection_id),
      clock_(clock),
      host_(host),
      spdy_request_framer_(HTTP2),
      spdy_response_framer_(HTTP2),
      perspective_(perspective) {}

QuicTestPacketMaker::~QuicTestPacketMaker() {}

void QuicTestPacketMaker::set_hostname(const std::string& host) {
  host_.assign(host);
}

std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakePingPacket(
    QuicPacketNumber num,
    bool include_version) {
  QuicPacketHeader header;
  header.public_header.connection_id = connection_id_;
  header.public_header.reset_flag = false;
  header.public_header.version_flag = include_version;
  header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
  header.packet_number = num;

  QuicPingFrame ping;
  return std::unique_ptr<QuicReceivedPacket>(
      MakePacket(header, QuicFrame(ping)));
}

std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakeRstPacket(
    QuicPacketNumber num,
    bool include_version,
    QuicStreamId stream_id,
    QuicRstStreamErrorCode error_code) {
  return MakeRstPacket(num, include_version, stream_id, error_code, 0);
}

std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakeRstPacket(
    QuicPacketNumber num,
    bool include_version,
    QuicStreamId stream_id,
    QuicRstStreamErrorCode error_code,
    size_t bytes_written) {
  QuicPacketHeader header;
  header.public_header.connection_id = connection_id_;
  header.public_header.reset_flag = false;
  header.public_header.version_flag = include_version;
  header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
  header.packet_number = num;

  QuicRstStreamFrame rst(stream_id, error_code, bytes_written);
  DVLOG(1) << "Adding frame: " << QuicFrame(&rst);
  return std::unique_ptr<QuicReceivedPacket>(
      MakePacket(header, QuicFrame(&rst)));
}

std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakeAckAndRstPacket(
    QuicPacketNumber num,
    bool include_version,
    QuicStreamId stream_id,
    QuicRstStreamErrorCode error_code,
    QuicPacketNumber largest_received,
    QuicPacketNumber ack_least_unacked,
    QuicPacketNumber stop_least_unacked,
    bool send_feedback) {
  QuicPacketHeader header;
  header.public_header.connection_id = connection_id_;
  header.public_header.reset_flag = false;
  header.public_header.version_flag = include_version;
  header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
  header.packet_number = num;

  QuicAckFrame ack(MakeAckFrame(largest_received));
  ack.ack_delay_time = QuicTime::Delta::Zero();
  for (QuicPacketNumber i = ack_least_unacked; i <= largest_received; ++i) {
    ack.received_packet_times.push_back(make_pair(i, clock_->Now()));
  }
  if (largest_received > 0) {
    ack.packets.Add(1, largest_received + 1);
  }
  QuicFrames frames;
  frames.push_back(QuicFrame(&ack));
  DVLOG(1) << "Adding frame: " << frames[0];

  QuicStopWaitingFrame stop_waiting;
  stop_waiting.least_unacked = stop_least_unacked;
  frames.push_back(QuicFrame(&stop_waiting));
  DVLOG(1) << "Adding frame: " << frames[1];

  QuicRstStreamFrame rst(stream_id, error_code, 0);
  frames.push_back(QuicFrame(&rst));
  DVLOG(1) << "Adding frame: " << frames[2];

  QuicFramer framer(SupportedVersions(version_), clock_->Now(), perspective_);
  std::unique_ptr<QuicPacket> packet(
      BuildUnsizedDataPacket(&framer, header, frames));
  char buffer[kMaxPacketSize];
  size_t encrypted_size = framer.EncryptPayload(ENCRYPTION_NONE, /*path_id=*/0u,
                                                header.packet_number, *packet,
                                                buffer, kMaxPacketSize);
  EXPECT_NE(0u, encrypted_size);
  QuicReceivedPacket encrypted(buffer, encrypted_size, QuicTime::Zero(), false);
  return std::unique_ptr<QuicReceivedPacket>(encrypted.Clone());
}

std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeAckAndConnectionClosePacket(
    QuicPacketNumber num,
    bool include_version,
    QuicTime::Delta ack_delay_time,
    QuicPacketNumber largest_received,
    QuicPacketNumber least_unacked,
    QuicErrorCode quic_error,
    const std::string& quic_error_details) {
  QuicPacketHeader header;
  header.public_header.connection_id = connection_id_;
  header.public_header.reset_flag = false;
  header.public_header.version_flag = include_version;
  header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
  header.packet_number = num;

  QuicAckFrame ack(MakeAckFrame(largest_received));
  ack.ack_delay_time = ack_delay_time;
  for (QuicPacketNumber i = least_unacked; i <= largest_received; ++i) {
    ack.received_packet_times.push_back(make_pair(i, clock_->Now()));
  }
  if (largest_received > 0) {
    ack.packets.Add(1, largest_received + 1);
  }
  QuicFrames frames;
  frames.push_back(QuicFrame(&ack));
  DVLOG(1) << "Adding frame: " << frames[0];

  QuicStopWaitingFrame stop_waiting;
  stop_waiting.least_unacked = least_unacked;
  frames.push_back(QuicFrame(&stop_waiting));
  DVLOG(1) << "Adding frame: " << frames[1];

  QuicConnectionCloseFrame close;
  close.error_code = quic_error;
  close.error_details = quic_error_details;

  frames.push_back(QuicFrame(&close));
  DVLOG(1) << "Adding frame: " << frames[2];

  QuicFramer framer(SupportedVersions(version_), clock_->Now(), perspective_);
  std::unique_ptr<QuicPacket> packet(
      BuildUnsizedDataPacket(&framer, header, frames));
  char buffer[kMaxPacketSize];
  size_t encrypted_size = framer.EncryptPayload(ENCRYPTION_NONE, /*path_id=*/0u,
                                                header.packet_number, *packet,
                                                buffer, kMaxPacketSize);
  EXPECT_NE(0u, encrypted_size);
  QuicReceivedPacket encrypted(buffer, encrypted_size, clock_->Now(), false);
  return std::unique_ptr<QuicReceivedPacket>(encrypted.Clone());
}

std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeConnectionClosePacket(QuicPacketNumber num) {
  QuicPacketHeader header;
  header.public_header.connection_id = connection_id_;
  header.public_header.reset_flag = false;
  header.public_header.version_flag = false;
  header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
  header.packet_number = num;

  QuicConnectionCloseFrame close;
  close.error_code = QUIC_CRYPTO_VERSION_NOT_SUPPORTED;
  close.error_details = "Time to panic!";
  return std::unique_ptr<QuicReceivedPacket>(
      MakePacket(header, QuicFrame(&close)));
}

std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakeGoAwayPacket(
    QuicPacketNumber num,
    QuicErrorCode error_code,
    std::string reason_phrase) {
  QuicPacketHeader header;
  header.public_header.connection_id = connection_id_;
  header.public_header.reset_flag = false;
  header.public_header.version_flag = false;
  header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
  header.packet_number = num;

  QuicGoAwayFrame goaway;
  goaway.error_code = error_code;
  goaway.last_good_stream_id = 0;
  goaway.reason_phrase = reason_phrase;
  return std::unique_ptr<QuicReceivedPacket>(
      MakePacket(header, QuicFrame(&goaway)));
}

// Sets both least_unacked fields in stop waiting frame and ack frame
// to be |least_unacked|.
std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakeAckPacket(
    QuicPacketNumber packet_number,
    QuicPacketNumber largest_received,
    QuicPacketNumber least_unacked,
    bool send_feedback) {
  return MakeAckPacket(packet_number, largest_received, least_unacked,
                       least_unacked, send_feedback);
}

std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakeAckPacket(
    QuicPacketNumber packet_number,
    QuicPacketNumber largest_received,
    QuicPacketNumber ack_least_unacked,
    QuicPacketNumber stop_least_unacked,
    bool send_feedback) {
  QuicPacketHeader header;
  header.public_header.connection_id = connection_id_;
  header.public_header.reset_flag = false;
  header.public_header.version_flag = false;
  header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
  header.packet_number = packet_number;

  QuicAckFrame ack(MakeAckFrame(largest_received));
  ack.ack_delay_time = QuicTime::Delta::Zero();
  for (QuicPacketNumber i = ack_least_unacked; i <= largest_received; ++i) {
    ack.received_packet_times.push_back(make_pair(i, clock_->Now()));
  }
  if (largest_received > 0) {
    ack.packets.Add(1, largest_received + 1);
  }

  QuicFramer framer(SupportedVersions(version_), clock_->Now(), perspective_);
  QuicFrames frames;
  QuicFrame ack_frame(&ack);
  DVLOG(1) << "Adding frame: " << ack_frame;
  frames.push_back(ack_frame);

  QuicStopWaitingFrame stop_waiting;
  stop_waiting.least_unacked = stop_least_unacked;
  frames.push_back(QuicFrame(&stop_waiting));

  std::unique_ptr<QuicPacket> packet(
      BuildUnsizedDataPacket(&framer, header, frames));
  char buffer[kMaxPacketSize];
  size_t encrypted_size = framer.EncryptPayload(ENCRYPTION_NONE, /*path_id=*/0u,
                                                header.packet_number, *packet,
                                                buffer, kMaxPacketSize);
  EXPECT_NE(0u, encrypted_size);
  QuicReceivedPacket encrypted(buffer, encrypted_size, clock_->Now(), false);
  return std::unique_ptr<QuicReceivedPacket>(encrypted.Clone());
}

// Returns a newly created packet to send kData on stream 1.
std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakeDataPacket(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    bool should_include_version,
    bool fin,
    QuicStreamOffset offset,
    base::StringPiece data) {
  InitializeHeader(packet_number, should_include_version);
  QuicStreamFrame frame(stream_id, fin, offset, data);
  DVLOG(1) << "Adding frame: " << frame;
  return MakePacket(header_, QuicFrame(&frame));
}

std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeMultipleDataFramesPacket(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    bool should_include_version,
    bool fin,
    QuicStreamOffset offset,
    const std::vector<std::string>& data_writes) {
  InitializeHeader(packet_number, should_include_version);
  QuicFrames data_frames;
  // QuicFrame takes a raw pointer. Use a std::vector here so we keep
  // StreamFrames alive until MakeMultipleFramesPacket is done.
  std::vector<std::unique_ptr<QuicStreamFrame>> stream_frames;
  for (size_t i = 0; i < data_writes.size(); ++i) {
    bool is_fin = fin && (i == data_writes.size() - 1);
    stream_frames.push_back(base::MakeUnique<QuicStreamFrame>(
        stream_id, is_fin, offset, base::StringPiece(data_writes[i])));
    offset += data_writes[i].length();
  }
  for (const auto& stream_frame : stream_frames) {
    QuicFrame quic_frame(stream_frame.get());
    DVLOG(1) << "Adding frame: " << quic_frame;
    data_frames.push_back(quic_frame);
  }
  return MakeMultipleFramesPacket(header_, data_frames);
}

std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakeAckAndDataPacket(
    QuicPacketNumber packet_number,
    bool include_version,
    QuicStreamId stream_id,
    QuicPacketNumber largest_received,
    QuicPacketNumber least_unacked,
    bool fin,
    QuicStreamOffset offset,
    base::StringPiece data) {
  InitializeHeader(packet_number, include_version);

  QuicAckFrame ack(MakeAckFrame(largest_received));
  ack.ack_delay_time = QuicTime::Delta::Zero();
  for (QuicPacketNumber i = least_unacked; i <= largest_received; ++i) {
    ack.received_packet_times.push_back(make_pair(i, clock_->Now()));
  }
  if (largest_received > 0) {
    ack.packets.Add(1, largest_received + 1);
  }
  QuicFrames frames;
  frames.push_back(QuicFrame(&ack));

  QuicStopWaitingFrame stop_waiting;
  stop_waiting.least_unacked = least_unacked;
  frames.push_back(QuicFrame(&stop_waiting));

  QuicStreamFrame stream_frame(stream_id, fin, offset, data);
  frames.push_back(QuicFrame(&stream_frame));

  return MakeMultipleFramesPacket(header_, frames);
}

std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeRequestHeadersAndMultipleDataFramesPacket(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    bool should_include_version,
    bool fin,
    SpdyPriority priority,
    SpdyHeaderBlock headers,
    size_t* spdy_headers_frame_length,
    const std::vector<std::string>& data_writes) {
  InitializeHeader(packet_number, should_include_version);
  SpdySerializedFrame spdy_frame;
  SpdyHeadersIR headers_frame(stream_id, std::move(headers));
  headers_frame.set_fin(fin);
  headers_frame.set_weight(Spdy3PriorityToHttp2Weight(priority));
  headers_frame.set_has_priority(true);
  spdy_frame = spdy_request_framer_.SerializeFrame(headers_frame);

  if (spdy_headers_frame_length) {
    *spdy_headers_frame_length = spdy_frame.size();
  }
  QuicStreamFrame frame(
      kHeadersStreamId, false, 0,
      base::StringPiece(spdy_frame.data(), spdy_frame.size()));

  QuicFrames frames;
  frames.push_back(QuicFrame(&frame));

  QuicStreamOffset offset = 0;
  // QuicFrame takes a raw pointer. Use a std::vector here so we keep
  // StreamFrames alive until MakeMultipleFramesPacket is done.
  std::vector<std::unique_ptr<QuicStreamFrame>> stream_frames;
  for (size_t i = 0; i < data_writes.size(); ++i) {
    bool is_fin = fin && (i == data_writes.size() - 1);
    stream_frames.push_back(base::MakeUnique<QuicStreamFrame>(
        stream_id, is_fin, offset, base::StringPiece(data_writes[i])));
    offset += data_writes[i].length();
  }
  for (const auto& stream_frame : stream_frames) {
    QuicFrame quic_frame(stream_frame.get());
    DVLOG(1) << "Adding frame: " << quic_frame;
    frames.push_back(quic_frame);
  }
  return MakeMultipleFramesPacket(header_, frames);
}

std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeRequestHeadersPacket(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    bool should_include_version,
    bool fin,
    SpdyPriority priority,
    SpdyHeaderBlock headers,
    size_t* spdy_headers_frame_length) {
  return MakeRequestHeadersPacket(
      packet_number, stream_id, should_include_version, fin, priority,
      std::move(headers), spdy_headers_frame_length, nullptr);
}

// If |offset| is provided, will use the value when creating the packet.
// Will also update the value after packet creation.
std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeRequestHeadersPacket(QuicPacketNumber packet_number,
                                              QuicStreamId stream_id,
                                              bool should_include_version,
                                              bool fin,
                                              SpdyPriority priority,
                                              SpdyHeaderBlock headers,
                                              size_t* spdy_headers_frame_length,
                                              QuicStreamOffset* offset) {
  InitializeHeader(packet_number, should_include_version);
  SpdySerializedFrame spdy_frame;
  SpdyHeadersIR headers_frame(stream_id, std::move(headers));
  headers_frame.set_fin(fin);
  headers_frame.set_weight(Spdy3PriorityToHttp2Weight(priority));
  headers_frame.set_has_priority(true);
  spdy_frame = spdy_request_framer_.SerializeFrame(headers_frame);

  if (spdy_headers_frame_length) {
    *spdy_headers_frame_length = spdy_frame.size();
  }
  if (offset != nullptr) {
    QuicStreamFrame frame(
        kHeadersStreamId, false, *offset,
        base::StringPiece(spdy_frame.data(), spdy_frame.size()));
    *offset += spdy_frame.size();
    return MakePacket(header_, QuicFrame(&frame));
  } else {
    QuicStreamFrame frame(
        kHeadersStreamId, false, 0,
        base::StringPiece(spdy_frame.data(), spdy_frame.size()));

    return MakePacket(header_, QuicFrame(&frame));
  }
}

// Convenience method for calling MakeRequestHeadersPacket with nullptr for
// |spdy_headers_frame_length|.
std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeRequestHeadersPacketWithOffsetTracking(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    bool should_include_version,
    bool fin,
    SpdyPriority priority,
    SpdyHeaderBlock headers,
    QuicStreamOffset* offset) {
  return MakeRequestHeadersPacket(packet_number, stream_id,
                                  should_include_version, fin, priority,
                                  std::move(headers), nullptr, offset);
}

// If |offset| is provided, will use the value when creating the packet.
// Will also update the value after packet creation.
std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakePushPromisePacket(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    QuicStreamId promised_stream_id,
    bool should_include_version,
    bool fin,
    SpdyHeaderBlock headers,
    size_t* spdy_headers_frame_length,
    QuicStreamOffset* offset) {
  InitializeHeader(packet_number, should_include_version);
  SpdySerializedFrame spdy_frame;
  SpdyPushPromiseIR promise_frame(stream_id, promised_stream_id,
                                  std::move(headers));
  promise_frame.set_fin(fin);
  spdy_frame = spdy_request_framer_.SerializeFrame(promise_frame);
  if (spdy_headers_frame_length) {
    *spdy_headers_frame_length = spdy_frame.size();
  }
  if (offset != nullptr) {
    QuicStreamFrame frame(
        kHeadersStreamId, false, *offset,
        base::StringPiece(spdy_frame.data(), spdy_frame.size()));
    *offset += spdy_frame.size();
    return MakePacket(header_, QuicFrame(&frame));
  } else {
    QuicStreamFrame frame(
        kHeadersStreamId, false, 0,
        base::StringPiece(spdy_frame.data(), spdy_frame.size()));
    return MakePacket(header_, QuicFrame(&frame));
  }
}

std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakeForceHolDataPacket(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    bool should_include_version,
    bool fin,
    QuicStreamOffset* offset,
    base::StringPiece data) {
  SpdyDataIR spdy_data(stream_id, data);
  spdy_data.set_fin(fin);
  SpdySerializedFrame spdy_frame(
      spdy_request_framer_.SerializeFrame(spdy_data));
  InitializeHeader(packet_number, should_include_version);
  QuicStreamFrame quic_frame(kHeadersStreamId, false, *offset,
                             StringPiece(spdy_frame.data(), spdy_frame.size()));
  *offset += spdy_frame.size();
  return MakePacket(header_, QuicFrame(&quic_frame));
}

// If |offset| is provided, will use the value when creating the packet.
// Will also update the value after packet creation.
std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeResponseHeadersPacket(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    bool should_include_version,
    bool fin,
    SpdyHeaderBlock headers,
    size_t* spdy_headers_frame_length,
    QuicStreamOffset* offset) {
  InitializeHeader(packet_number, should_include_version);
  SpdySerializedFrame spdy_frame;
  SpdyHeadersIR headers_frame(stream_id, std::move(headers));
  headers_frame.set_fin(fin);
  spdy_frame = spdy_response_framer_.SerializeFrame(headers_frame);

  if (spdy_headers_frame_length) {
    *spdy_headers_frame_length = spdy_frame.size();
  }
  if (offset != nullptr) {
    QuicStreamFrame frame(
        kHeadersStreamId, false, *offset,
        base::StringPiece(spdy_frame.data(), spdy_frame.size()));
    *offset += spdy_frame.size();
    return MakePacket(header_, QuicFrame(&frame));
  } else {
    QuicStreamFrame frame(
        kHeadersStreamId, false, 0,
        base::StringPiece(spdy_frame.data(), spdy_frame.size()));
    return MakePacket(header_, QuicFrame(&frame));
  }
}

std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeResponseHeadersPacket(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    bool should_include_version,
    bool fin,
    SpdyHeaderBlock headers,
    size_t* spdy_headers_frame_length) {
  return MakeResponseHeadersPacket(
      packet_number, stream_id, should_include_version, fin, std::move(headers),
      spdy_headers_frame_length, nullptr);
}

// Convenience method for calling MakeResponseHeadersPacket with nullptr for
// |spdy_headers_frame_length|.
std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeResponseHeadersPacketWithOffsetTracking(
    QuicPacketNumber packet_number,
    QuicStreamId stream_id,
    bool should_include_version,
    bool fin,
    SpdyHeaderBlock headers,
    QuicStreamOffset* offset) {
  return MakeResponseHeadersPacket(packet_number, stream_id,
                                   should_include_version, fin,
                                   std::move(headers), nullptr, offset);
}

SpdyHeaderBlock QuicTestPacketMaker::GetRequestHeaders(
    const std::string& method,
    const std::string& scheme,
    const std::string& path) {
  SpdyHeaderBlock headers;
  headers[":method"] = method;
  headers[":authority"] = host_;
  headers[":scheme"] = scheme;
  headers[":path"] = path;
  return headers;
}

SpdyHeaderBlock QuicTestPacketMaker::GetResponseHeaders(
    const std::string& status) {
  SpdyHeaderBlock headers;
  headers[":status"] = status;
  headers["content-type"] = "text/plain";
  return headers;
}

SpdyHeaderBlock QuicTestPacketMaker::GetResponseHeaders(
    const std::string& status,
    const std::string& alt_svc) {
  SpdyHeaderBlock headers;
  headers[":status"] = status;
  headers["alt-svc"] = alt_svc;
  headers["content-type"] = "text/plain";
  return headers;
}

std::unique_ptr<QuicReceivedPacket> QuicTestPacketMaker::MakePacket(
    const QuicPacketHeader& header,
    const QuicFrame& frame) {
  QuicFrames frames;
  frames.push_back(frame);
  return MakeMultipleFramesPacket(header, frames);
}

std::unique_ptr<QuicReceivedPacket>
QuicTestPacketMaker::MakeMultipleFramesPacket(const QuicPacketHeader& header,
                                              const QuicFrames& frames) {
  QuicFramer framer(SupportedVersions(version_), clock_->Now(), perspective_);
  std::unique_ptr<QuicPacket> packet(
      BuildUnsizedDataPacket(&framer, header, frames));
  char buffer[kMaxPacketSize];
  size_t encrypted_size = framer.EncryptPayload(ENCRYPTION_NONE, /*path_id=*/0u,
                                                header.packet_number, *packet,
                                                buffer, kMaxPacketSize);
  EXPECT_NE(0u, encrypted_size);
  QuicReceivedPacket encrypted(buffer, encrypted_size, clock_->Now(), false);
  return std::unique_ptr<QuicReceivedPacket>(encrypted.Clone());
}

void QuicTestPacketMaker::InitializeHeader(QuicPacketNumber packet_number,
                                           bool should_include_version) {
  header_.public_header.connection_id = connection_id_;
  header_.public_header.reset_flag = false;
  header_.public_header.version_flag = should_include_version;
  header_.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
  header_.packet_number = packet_number;
}

}  // namespace test
}  // namespace net


text:
/*jslint node: true */
/*jshint unused: false */
'use strict';

/**
 * Module dependencies.
 */

if (process.env.NEW_RELIC_LICENSE_KEY) {
  console.log('New Relic in use.');
  require('newrelic');
} else {
  console.log('New Relic not in use.');
}

var SwaggerExpress = require('swagger-express-mw');
var SwaggerUi = require('swagger-tools/middleware/swagger-ui');
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var app = require('express')();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);

module.exports = app; // for testing

var config = {
  appRoot: __dirname, // required config
};

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: err,
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {},
  });
});

SwaggerExpress.create(config, function(err, swaggerExpress) {
  if (err) {
    throw err;
  }

  // add swagger-ui
  app.use(new SwaggerUi(swaggerExpress.runner.swagger));

  // install middleware
  swaggerExpress.register(app);

  var port = process.env.VCAP_APP_PORT || 3000;
  app.listen(port);
});


text:
package org.foo.shell;

import java.io.PrintStream;
import java.util.Map;

public class HelpCommand extends BasicCommand {
  private final Map<String, Command> m_commands;

  public HelpCommand(Map<String, Command> commands) {
    m_commands = commands;
  }

  public void exec(String args, PrintStream out, PrintStream err) {
    for (Command command : m_commands.values()) {
      out.println(command);
    }
  }
}


text:
typedef struct _E_Int_Menu_Augmentation E_Int_Menu_Augmentation;

#else
#ifndef E_INT_MENUS_H
#define E_INT_MENUS_H

#define E_CLIENTLIST_GROUP_NONE 0
#define E_CLIENTLIST_GROUP_DESK 1
#define E_CLIENTLIST_GROUP_CLASS 2

#define E_CLIENTLIST_GROUP_SEP_NONE 0
#define E_CLIENTLIST_GROUP_SEP_BAR 1
#define E_CLIENTLIST_GROUP_SEP_MENU 2

#define E_CLIENTLIST_SORT_NONE 0
#define E_CLIENTLIST_SORT_ALPHA 1
#define E_CLIENTLIST_SORT_ZORDER 2
#define E_CLIENTLIST_SORT_MOST_RECENT 3

#define E_CLIENTLIST_GROUPICONS_OWNER 0
#define E_CLIENTLIST_GROUPICONS_CURRENT 1
#define E_CLIENTLIST_GROUPICONS_SEP 2

#define E_CLIENTLIST_MAX_CAPTION_LEN 256

struct _E_Int_Menu_Augmentation
{
   const char *sort_key;
   struct
     {
        void (*func) (void *data, E_Menu *m);
        void *data;
     } add, del;
};

EAPI E_Menu *e_int_menus_main_new(void);
EAPI E_Menu *e_int_menus_desktops_new(void);
EAPI E_Menu *e_int_menus_clients_new(void);
EAPI E_Menu *e_int_menus_apps_new(const char *dir);
EAPI E_Menu *e_int_menus_favorite_apps_new(void);
EAPI E_Menu *e_int_menus_all_apps_new(void);
EAPI E_Menu *e_int_menus_config_new(void);
EAPI E_Menu *e_int_menus_lost_clients_new(void);
EAPI E_Menu *e_int_menus_shelves_new(void);

EAPI E_Int_Menu_Augmentation *e_int_menus_menu_augmentation_add(const char *menu,
								void (*func_add) (void *data, E_Menu *m),
								void *data_add,
								void (*func_del) (void *data, E_Menu *m),
								void *data_del);
EAPI E_Int_Menu_Augmentation *e_int_menus_menu_augmentation_add_sorted(const char *menu,
								       const char *sort_key,
								       void (*func_add) (void *data, E_Menu *m),
								       void *data_add,
								       void (*func_del) (void *data, E_Menu *m),
								       void *data_del);
EAPI void                     e_int_menus_menu_augmentation_del(const char *menu,
								E_Int_Menu_Augmentation *maug);

EAPI void                     e_int_menus_menu_augmentation_point_disabled_set(const char *menu,
                                       Eina_Bool disabled);

EINTERN void e_int_menus_init(void);
EINTERN void e_int_menus_shutdown(void);
#endif
#endif


text:
package org.jasig.cas.web.flow;

import org.springframework.stereotype.Component;
import org.springframework.webflow.engine.ActionState;
import org.springframework.webflow.engine.Flow;

/**
 * The {@link TrustedAuthenticationWebflowConfigurer} is responsible for
 * adjusting the CAS webflow context for trusted authn integration.
 *
 * @author Misagh Moayyed
 * @since 4.2
 */
@Component("trustedWebflowConfigurer")
public class TrustedAuthenticationWebflowConfigurer extends AbstractCasWebflowConfigurer {

    @Override
    protected void doInitialize() throws Exception {
        final Flow flow = getLoginFlow();
        final ActionState actionState = createActionState(flow, "remoteAuthenticate",
                createEvaluateAction("principalFromRemoteUserAction"));
        actionState.getTransitionSet().add(createTransition(TRANSITION_ID_SUCCESS, TRANSITION_ID_SEND_TICKET_GRANTING_TICKET));
        actionState.getTransitionSet().add(createTransition(TRANSITION_ID_ERROR, getStartState(flow).getId()));
        setStartState(flow, actionState);
    }
}


text:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using StreamCompanionTypes.DataTypes;
using StreamCompanionTypes.Interfaces.Services;

namespace WebSocketDataSender.WebOverlay
{
    internal static class ColorHelpers
    {
        public static string GetArgbColor(ISettings settings, ConfigEntry entry)
        => string.Join("", GetArgbColorList(settings, entry).Select(n => n.ToString("X2")));

        public static List<int> GetArgbColorList(ISettings settings, ConfigEntry entry)
            => settings.Get<string>(entry).Split(new[] { ';' }, 4).Select(v => int.TryParse(v, out int num) ? num : 0).ToList();

        public static Color GetColor(ISettings settings, ConfigEntry entry)
        {
            var argb = GetArgbColorList(settings, entry);

            return Color.FromArgb(argb[0], argb[1], argb[2], argb[3]);
        }

        public static void SaveColor(ISettings settings, ConfigEntry entry, Color color)
        {
            var colors = BitConverter.GetBytes(color.ToArgb())
                .Reverse()
                .ToList();

            settings.Add(entry.Name, string.Join(";", colors.Select(v => v.ToString())), true);
        }
    }
}


text:
title: Responsive Web Design
author: Ethan Marcotte
cover: /images/books/responsive-web-design.gif
link: http://www.abookapart.com/products/responsive-web-design
---


text:
/* jshint node: true */
'use strict';

var path = require('path');

module.exports = {
  name: 'ember-data',
  blueprintsPath: function() {
    return path.join(__dirname, 'blueprints');
  },
  included: function(app) {
    this._super.included(app);

    var options = {
      exports: {
        'ember-data': [
          'default'
        ]
      }
    };

    this.app.import({
      development: app.bowerDirectory + '/ember-data/ember-data.js',
      production: app.bowerDirectory + '/ember-data/ember-data.prod.js'
    }, options);
    // Source maps
    this.app.import({
      development: app.bowerDirectory + '/ember-data/ember-data.js.map'
    }, {destDir: 'assets'});
  }
};


text:
export default {
	test({ assert, target }) {
		// Test for
 tag
		const elementPre = target.querySelector('#pre');
		// Test for non
 tag
		const elementDiv = target.querySelector('#div');
		// Test for
 tag in non
 tag
		const elementDivWithPre = target.querySelector('#div-with-pre');
		// Test for
 tag with leading newline
		const elementPreWithLeadingNewline = target.querySelector('#pre-with-leading-newline');
		const elementPreWithoutLeadingNewline = target.querySelector('#pre-without-leading-newline');
		const elementPreWithMultipleLeadingNewline = target.querySelector('#pre-with-multiple-leading-newlines');

		assert.equal(
			elementPre.innerHTML,
			`  A
  B

    C
    D

  E
  F
`
		);
		assert.equal(
			elementDiv.innerHTML,
			`A
  B
  C
    D
  E
  F`
		);
		assert.equal(
			elementDivWithPre.innerHTML,
			`
    A
    B

      C
      D

    E
    F

`
		);
		assert.equal(elementPreWithLeadingNewline.children[0].innerHTML, 'leading newline');
		assert.equal(elementPreWithLeadingNewline.children[1].innerHTML, '  leading newline and spaces');
		assert.equal(elementPreWithLeadingNewline.children[2].innerHTML, '\nleading newlines');
		assert.equal(elementPreWithoutLeadingNewline.children[0].innerHTML, 'without spaces');
		assert.equal(elementPreWithoutLeadingNewline.children[1].innerHTML, '  with spaces  ');
		assert.equal(elementPreWithoutLeadingNewline.children[2].innerHTML, ' \nnewline after leading space');
		assert.equal(elementPreWithMultipleLeadingNewline.innerHTML, '\n\nmultiple leading newlines');
	}
};


text:
using System.ComponentModel.DataAnnotations;

namespace Sakura.AspNetCore.Mvc.TagHelpers
{
	/// <summary>
	///     Define the text source for text generators for a relection items.
	/// </summary>
	public enum TextSource
	{
		/// <summary>
		///     Use the member name as the text.
		/// </summary>
		MemberNameOnly = 0,

		/// <summary>
		///     If <see cref="DisplayAttribute" /> is defined and <see cref="DisplayAttribute.Name" /> is provided, use its value;
		///     Otherwise, fallback to the <see cref="MemberNameOnly" /> option.
		/// </summary>
		Name,

		/// <summary>
		///     If <see cref="DisplayAttribute" /> is defined and <see cref="DisplayAttribute.ShortName" /> is provided, use its
		///     value; Otherwise, fallback to the <see cref="MemberNameOnly" /> option.
		/// </summary>
		ShortName,

		/// <summary>
		///     If <see cref="DisplayAttribute" /> is defined and <see cref="DisplayAttribute.Description" /> is provided, use its
		///     value; Otherwise, fallback to the <see cref="MemberNameOnly" /> option.
		/// </summary>
		Description
	}
}


text:
<?xml version="1.0"?>
<Document>

	<Sentence>
		<value>Acute cystitis is an infection of the bladder or lower urinary tract.</value>
		<pattern_crowdsource> [[Acute cystitis|C0149523]] is an [[infection|C0009450]] of the [[bladder|C0005682]] or lower urinary tract.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>Acute cystitis</surface-form>
				<RDF-ID>C0149523</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infection</surface-form>
				<RDF-ID>C0009450</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bladder</surface-form>
				<RDF-ID>C0005682</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>lower urinary tract</surface-form>
				<RDF-ID>C0729866</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0149523 ISA C0009450</triple>
			<triple>C0005682 LOCATION_OF C0009450</triple>
			<triple>C0005682 LOCATION_OF C0149523</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>The infection commonly develops in the bladder.</value>
		<pattern_crowdsource> The [[infection|C0009450]] commonly develops in the [[bladder|C0005682]].		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>infection</surface-form>
				<RDF-ID>C0009450</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bladder</surface-form>
				<RDF-ID>C0005682</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0005682 LOCATION_OF C0009450</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>Most of the time, your body can get rid of these bacteria when you urinate.</value>
		<pattern_crowdsource> Most of the time, your body can get [[rid|C0073361]] of these [[bacteria|C0004611]] when you urinate.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>Most</surface-form>
				<RDF-ID>C0205393</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>time</surface-form>
				<RDF-ID>C0040223</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>rid</surface-form>
				<RDF-ID>C0073361</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bacteria</surface-form>
				<RDF-ID>C0004611</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0004611 LOCATION_OF C0073361</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>But, the bacteria can stick to the wall of the urethra or bladder, or grow so fast that some stay in the bladder.</value>
		<pattern_crowdsource> But, the [[bacteria|C0004611]] can stick to the wall of the urethra or bladder, or grow so fast that some stay in the [[bladder|C0005682]].		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>bacteria</surface-form>
				<RDF-ID>C0004611</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urethra</surface-form>
				<RDF-ID>C0041967</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bladder</surface-form>
				<RDF-ID>C0005682</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>fast</surface-form>
				<RDF-ID>C0456962</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bladder</surface-form>
				<RDF-ID>C0005682</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0005682 LOCATION_OF C0004611</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>The following also increase your chances of having cystitis:  - A tube called a urinary catheter inserted in your bladder  - Blockage of the bladder or urethra  - Diabetes  - Enlarged prostate, narrowed urethra, or anything that blocks the flow of urine  - Loss of bowel control (bowel incontinence)  - Older age (especially in people who live in nursing homes)  - Pregnancy  - Problems fully emptying your bladder (urinary retention)  - Procedures that involve the urinary tract  - Staying still (immobile) for a long period of time (for example, when you are recovering from a hip fracture)    Most cases are caused by Escherichia coli (E. coli), a type of bacteria found in the intestines.</value>
		<pattern_crowdsource> The following also increase your chances of having cystitis:  - A tube called a urinary catheter inserted in your bladder  - Blockage of the bladder or urethra  - Diabetes  - Enlarged prostate, narrowed urethra, or anything that blocks the flow of urine  - Loss of [[bowel control|C1290944]] (bowel incontinence)  - Older age (especially in people who live in nursing homes)  - Pregnancy  - Problems fully emptying your bladder (urinary retention)  - Procedures that involve the urinary tract  - Staying still (immobile) for a long period of time (for example, when you are recovering from a hip fracture)    Most cases are caused by [[Escherichia coli|C0014834]] (E. coli), a type of [[bacteria|C0004611]] found in the [[intestines|C0021853]].		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>chances</surface-form>
				<RDF-ID>C0237506</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>cystitis</surface-form>
				<RDF-ID>C0010692</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>tube</surface-form>
				<RDF-ID>C1561954</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urinary catheter</surface-form>
				<RDF-ID>C0179802</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bladder</surface-form>
				<RDF-ID>C0005682</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bladder</surface-form>
				<RDF-ID>C0005682</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urethra</surface-form>
				<RDF-ID>C0041967</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Diabetes</surface-form>
				<RDF-ID>C0011847</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Enlarged prostate</surface-form>
				<RDF-ID>C0426732</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urethra</surface-form>
				<RDF-ID>C0041967</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>flow</surface-form>
				<RDF-ID>C0806140</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urine  - Loss</surface-form>
				<RDF-ID>C0429778</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bowel control</surface-form>
				<RDF-ID>C1290944</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bowel incontinence</surface-form>
				<RDF-ID>C0015732</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Older age</surface-form>
				<RDF-ID>C0001792</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>people</surface-form>
				<RDF-ID>C0027361</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>nursing homes</surface-form>
				<RDF-ID>C0028688</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Pregnancy  - Problems</surface-form>
				<RDF-ID>C0566639</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bladder</surface-form>
				<RDF-ID>C0005682</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urinary retention</surface-form>
				<RDF-ID>C0080274</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Procedures</surface-form>
				<RDF-ID>C0025664</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urinary tract</surface-form>
				<RDF-ID>C0042027</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>still</surface-form>
				<RDF-ID>C1410088</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>immobile</surface-form>
				<RDF-ID>C0231441</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>long</surface-form>
				<RDF-ID>C0205166</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>period</surface-form>
				<RDF-ID>C0439531</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>time</surface-form>
				<RDF-ID>C0040223</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>hip fracture</surface-form>
				<RDF-ID>C0019557</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Most</surface-form>
				<RDF-ID>C0205393</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>cases</surface-form>
				<RDF-ID>C0868928</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Escherichia coli</surface-form>
				<RDF-ID>C0014834</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>type</surface-form>
				<RDF-ID>C1547052</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bacteria</surface-form>
				<RDF-ID>C0004611</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>intestines</surface-form>
				<RDF-ID>C0021853</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0014834 CAUSES C1290944</triple>
			<triple>C0021853 LOCATION_OF C0004611</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>The symptoms of a bladder infection include:  - Cloudy or bloody urine  - Strong or foul smelling urine  - Low fever (not everyone will have a fever)  - Pain or burning with urination  - Pressure or cramping in the lower middle abdomen or back  - Strong need to urinate often, even right after the bladder has been emptied    Often in an elderly person, mental changes or confusion are the only signs of a possible urinary tract infection.</value>
		<pattern_crowdsource> The symptoms of a [[bladder infection|C0600041]] include:  - Cloudy or bloody urine  - Strong or foul smelling urine  - Low [[fever|C0015967]] (not everyone will have a fever)  - Pain or burning with urination  - Pressure or cramping in the [[lower middle abdomen|C0230166]] or back  - Strong need to urinate often, even right after the bladder has been emptied    Often in an [[elderly person|C0392363]], mental changes or confusion are the only signs of a possible urinary tract infection.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>symptoms</surface-form>
				<RDF-ID>C1457887</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bladder infection</surface-form>
				<RDF-ID>C0600041</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Cloudy</surface-form>
				<RDF-ID>C0205406</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bloody urine</surface-form>
				<RDF-ID>C0018965</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Strong</surface-form>
				<RDF-ID>C0442821</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>foul smelling urine</surface-form>
				<RDF-ID>C0549447</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Low</surface-form>
				<RDF-ID>C0205251</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>fever</surface-form>
				<RDF-ID>C0015967</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>not</surface-form>
				<RDF-ID>C1518422</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>fever</surface-form>
				<RDF-ID>C0015967</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Pain</surface-form>
				<RDF-ID>C0030193</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>burning</surface-form>
				<RDF-ID>C0175627</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urination</surface-form>
				<RDF-ID>C0042034</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Pressure</surface-form>
				<RDF-ID>C0234222</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>middle</surface-form>
				<RDF-ID>C0444598</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>lower middle abdomen</surface-form>
				<RDF-ID>C0230166</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>back</surface-form>
				<RDF-ID>C0205095</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Strong</surface-form>
				<RDF-ID>C0442821</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>need</surface-form>
				<RDF-ID>C0027552</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>often</surface-form>
				<RDF-ID>C0332183</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>right</surface-form>
				<RDF-ID>C0205090</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bladder</surface-form>
				<RDF-ID>C0005682</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Often</surface-form>
				<RDF-ID>C0332183</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>elderly person</surface-form>
				<RDF-ID>C0392363</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>mental</surface-form>
				<RDF-ID>C0229992</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>changes</surface-form>
				<RDF-ID>C0392747</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>confusion</surface-form>
				<RDF-ID>C0009676</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>signs</surface-form>
				<RDF-ID>C0311392</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>possible</surface-form>
				<RDF-ID>C0332149</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urinary tract infection</surface-form>
				<RDF-ID>C0042029</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0230166 LOCATION_OF C0015967</triple>
			<triple>C0600041 PROCESS_OF C0392363</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>This test is done to look for white blood cells, red blood cells, bacteria, and to check for certain chemicals, such as nitrites in the urine.</value>
		<pattern_crowdsource> This test is done to look for white blood cells, red blood cells, bacteria, and to check for certain [[chemicals|C0220806]], such as [[nitrites|C0028137]] in the urine.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>test</surface-form>
				<RDF-ID>C0039593</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>white blood cells</surface-form>
				<RDF-ID>C0023516</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>bacteria</surface-form>
				<RDF-ID>C0004611</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>certain</surface-form>
				<RDF-ID>C0205423</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>chemicals</surface-form>
				<RDF-ID>C0220806</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>nitrites</surface-form>
				<RDF-ID>C0028137</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urine</surface-form>
				<RDF-ID>C0042036</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0028137 ISA C0220806</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>Most of the time, your health care provider can diagnose an infection using a urinalysis.</value>
		<pattern_crowdsource> Most of the time, your [[health care provider|C0018724]] can diagnose an [[infection|C0009450]] using a urinalysis.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>Most</surface-form>
				<RDF-ID>C0205393</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>time</surface-form>
				<RDF-ID>C0040223</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>health care provider</surface-form>
				<RDF-ID>C0018724</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infection</surface-form>
				<RDF-ID>C0009450</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>urinalysis</surface-form>
				<RDF-ID>C0042014</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0018724 DIAGNOSES C0009450</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>Antibiotics taken by mouth are most often given to prevent the infection from spreading to the kidneys.</value>
		<pattern_crowdsource> [[Antibiotics|C0003232]] taken by mouth are most often given to prevent the [[infection|C0009450]] from spreading to the kidneys.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>Antibiotics</surface-form>
				<RDF-ID>C0003232</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>mouth</surface-form>
				<RDF-ID>C1278910</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>most</surface-form>
				<RDF-ID>C0205393</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>often</surface-form>
				<RDF-ID>C0332183</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infection</surface-form>
				<RDF-ID>C0009450</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>spreading</surface-form>
				<RDF-ID>C0332261</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>kidneys</surface-form>
				<RDF-ID>C0022646</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0003232 PREVENTS C0009450</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>People who do not finish their antibiotics may develop an infection that is harder to treat.</value>
		<pattern_crowdsource> [[People|C0027361]] who do not finish their antibiotics may develop an [[infection|C0009450]] that is harder to treat.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>People</surface-form>
				<RDF-ID>C0027361</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>not</surface-form>
				<RDF-ID>C1518422</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>antibiotics</surface-form>
				<RDF-ID>C0003232</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infection</surface-form>
				<RDF-ID>C0009450</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>harder</surface-form>
				<RDF-ID>C0018599</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0009450 PROCESS_OF C0027361</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>Phenazopyridine hydrochloride (Pyridium) is the most common of this type of drug.</value>
		<pattern_crowdsource> [[Phenazopyridine hydrochloride|C0700555]] ([[Pyridium|C0034259]]) is the most common of this type of [[drug|C0013227]].		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>Phenazopyridine hydrochloride</surface-form>
				<RDF-ID>C0700555</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>Pyridium</surface-form>
				<RDF-ID>C0034259</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>most</surface-form>
				<RDF-ID>C0205393</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>common</surface-form>
				<RDF-ID>C0205214</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>type</surface-form>
				<RDF-ID>C1547052</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>drug</surface-form>
				<RDF-ID>C0013227</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0034259 ISA C0700555</triple>
			<triple>C0034259 ISA C0013227</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>Your health care provider may suggest treatments such as:  - Taking a single dose of an antibiotic after sexual contact may prevent these infections if they occur after sexual activity.</value>
		<pattern_crowdsource> Your health care provider may suggest treatments such as:  - Taking a single dose of an [[antibiotic|C0003232]] after sexual contact may prevent these [[infections|C0021311]] if they occur after sexual activity.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>health care provider</surface-form>
				<RDF-ID>C0018724</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>treatments</surface-form>
				<RDF-ID>C0087111</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>single</surface-form>
				<RDF-ID>C0205171</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>dose</surface-form>
				<RDF-ID>C1446466</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>antibiotic</surface-form>
				<RDF-ID>C0003232</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infections</surface-form>
				<RDF-ID>C0021311</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>sexual activity</surface-form>
				<RDF-ID>C0036864</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0003232 PREVENTS C0021311</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>- Keeping a 3-day course of antibiotics at home to use for infections, based on their symptoms.</value>
		<pattern_crowdsource> - Keeping a 3-day course of [[antibiotics|C0003232]] at home to use for [[infections|C0021311]], based on their symptoms.		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>3-day</surface-form>
				<RDF-ID>C1442459</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>course</surface-form>
				<RDF-ID>C0750729</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>antibiotics</surface-form>
				<RDF-ID>C0003232</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infections</surface-form>
				<RDF-ID>C0021311</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>symptoms</surface-form>
				<RDF-ID>C1457887</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0003232 TREATS C0021311</triple>
		</triples>
	</Sentence>
	<Sentence>
		<value>- Taking a single, daily dose of an antibiotic to prevent infections.</value>
		<pattern_crowdsource> - Taking a single, daily dose of an [[antibiotic|C0003232]] to prevent [[infections|C0021311]].		</pattern_crowdsource>
		<annotations>
			<annotation>
				<surface-form>single</surface-form>
				<RDF-ID>C0205171</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>daily</surface-form>
				<RDF-ID>C0332173</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>dose</surface-form>
				<RDF-ID>C1446466</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>antibiotic</surface-form>
				<RDF-ID>C0003232</RDF-ID>
			</annotation>
			<annotation>
				<surface-form>infections</surface-form>
				<RDF-ID>C0021311</RDF-ID>
			</annotation>
		</annotations>
		<triples>
			<triple>C0003232 PREVENTS C0021311</triple>
		</triples>
	</Sentence>

</Document>


text:
#import <Social/Social.h>

#import "FBDialogs+Internal.h"
#import "FBSession.h"
#import "FBError.h"
#import "FBUtility.h"
#import "FBAppCall+Internal.h"
#import "FBAppBridge.h"
#import "FBAccessTokenData.h"
#import "FBInsights+Internal.h"
#import "FBDialogsParams+Internal.h"
#import "FBLoginDialogParams.h"
#import "FBShareDialogParams.h"
#import "FBOpenGraphActionShareDialogParams.h"
#import "FBDialogsData+Internal.h"
#import "FBAppLinkData+Internal.h"
#import "FBAccessTokenData+Internal.h"
#import "FBSettings.h"

static NSString *const kFBNativeLoginMinVersion = @"20130214";

@interface FBDialogs ()

+ (NSError*)createError:(NSString*)reason
                session:(FBSession *)session;

@end

@implementation FBDialogs

+ (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController*)viewController
                                      initialText:(NSString*)initialText
                                            image:(UIImage*)image
                                              url:(NSURL*)url
                                          handler:(FBOSIntegratedShareDialogHandler)handler {
    NSArray *images = image ? [NSArray arrayWithObject:image] : nil;
    NSArray *urls = url ? [NSArray arrayWithObject:url] : nil;

    return [self presentOSIntegratedShareDialogModallyFrom:viewController
                                                   session:nil
                                               initialText:initialText
                                                    images:images
                                                      urls:urls
                                                   handler:handler];
}

+ (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController*)viewController
                                      initialText:(NSString*)initialText
                                           images:(NSArray*)images
                                             urls:(NSArray*)urls
                                          handler:(FBOSIntegratedShareDialogHandler)handler {
    return [self presentOSIntegratedShareDialogModallyFrom:viewController
                                                   session:nil
                                               initialText:initialText
                                                    images:images
                                                      urls:urls
                                                   handler:handler];
}

+ (BOOL)presentOSIntegratedShareDialogModallyFrom:(UIViewController*)viewController
                                          session:(FBSession*)session
                                      initialText:(NSString*)initialText
                                           images:(NSArray*)images
                                             urls:(NSArray*)urls
                                          handler:(FBOSIntegratedShareDialogHandler)handler {
    SLComposeViewController *composeViewController = [FBDialogs composeViewControllerWithSession:session
                                                                                handler:handler];
    if (!composeViewController) {
        return NO;
    }

    if (initialText) {
        [composeViewController setInitialText:initialText];
    }
    if (images && images.count > 0) {
        for (UIImage *image in images) {
            [composeViewController addImage:image];
        }
    }
    if (urls && urls.count > 0) {
        for (NSURL *url in urls) {
            [composeViewController addURL:url];
        }
    }

    [composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) {
        BOOL cancelled = (result == SLComposeViewControllerResultCancelled);

        [FBInsights logImplicitEvent:FBInsightsEventNameShareSheetDismiss
                          valueToSum:1.0
                          parameters:@{ @"render_type" : @"Native",
FBInsightsEventParameterDialogOutcome : (cancelled
                                         ? FBInsightsDialogOutcomeValue_Cancelled
                                         : FBInsightsDialogOutcomeValue_Completed) }
                             session:session];

        if (handler) {
            handler(cancelled ?  FBOSIntegratedShareDialogResultCancelled :  FBOSIntegratedShareDialogResultSucceeded, nil);
        }
    }];

    [FBInsights logImplicitEvent:FBInsightsEventNameShareSheetLaunch
                      valueToSum:1.0
                      parameters:@{ @"render_type" : @"Native" }
                         session:session];
    [viewController presentModalViewController:composeViewController animated:YES];

    return YES;
}

+ (BOOL)canPresentOSIntegratedShareDialogWithSession:(FBSession*)session {
    return [FBDialogs composeViewControllerWithSession:session
                                               handler:nil] != nil;
}

// Private method to abstract away url polling for the present* and canPresent* methods for
// the FB Login Dialog
+ (NSString *)versionForLoginDialogWithParams:(FBLoginDialogParams *)params {
    // Select the right minimum version for the passed in combination of params.
    // NOTE: For now, there is only one.
    NSString *minVersion = kFBNativeLoginMinVersion;

    return [FBAppBridge installedFBNativeAppVersionForMethod:@"auth3" minVersion:minVersion];
}

+ (BOOL)canPresentLoginDialogWithParams:(FBLoginDialogParams *)params {
    NSString *version = [FBDialogs versionForLoginDialogWithParams:params];
    return (version != nil);
}

+ (FBAppCall *)presentLoginDialogWithParams:(FBLoginDialogParams *)params
                                  clientState:(NSDictionary *)clientState
                                      handler:(FBDialogAppCallCompletionHandler)handler {
    FBAppCall *call = nil;
    NSString *version = [FBDialogs versionForLoginDialogWithParams:params];
    if (version) {
        FBDialogsData *dialogData = [[[FBDialogsData alloc] initWithMethod:@"auth3"
                                                                 arguments:[params dictionaryMethodArgs]]
                                     autorelease];
        dialogData.clientState = clientState;

        call = [[[FBAppCall alloc] init] autorelease];
        call.dialogData = dialogData;

        // log the timestamp for starting the switch to the Facebook application
        [FBInsights logImplicitEvent:FBInsightsEventNameFBDialogsNativeLoginDialogStart
                          valueToSum:1.0
                          parameters:@{
                            FBInsightsNativeLoginDialogStartTime : [NSNumber numberWithDouble:round(1000 * [[NSDate date] timeIntervalSince1970])],
                            @"action_id" : [call ID],
                            @"app_id" : [FBSettings defaultAppID]
                          }
                          session:nil];
        [[FBAppBridge sharedInstance] dispatchDialogAppCall:call
                                                   version:version
                                         completionHandler:handler];
    }

    return call;
}

+ (BOOL)canPresentShareDialogWithParams:(FBShareDialogParams *)params {
    BOOL canPresent = [params appBridgeVersion] != nil;
    [FBInsights logImplicitEvent:FBInsightsEventNameFBDialogsCanPresentShareDialog
                      valueToSum:1.0
                      parameters:@{ FBInsightsEventParameterDialogOutcome :
                                         canPresent ?
                                            FBInsightsDialogOutcomeValue_Completed :
                                            FBInsightsDialogOutcomeValue_Failed }
                         session:nil];
    return canPresent;
}

+ (FBAppCall *)presentShareDialogWithParams:(FBShareDialogParams *)params
                                clientState:(NSDictionary *)clientState
                                    handler:(FBDialogAppCallCompletionHandler)handler {
    FBAppCall *call = nil;
    NSString *version = [params appBridgeVersion];
    if (version) {
        FBDialogsData *dialogData = [[[FBDialogsData alloc] initWithMethod:@"share"
                                                                 arguments:[params dictionaryMethodArgs]]
                                     autorelease];
        dialogData.clientState = clientState;

        call = [[[FBAppCall alloc] init] autorelease];
        call.dialogData = dialogData;

        [[FBAppBridge sharedInstance] dispatchDialogAppCall:call
                                                   version:version
                                         completionHandler:handler];
    }

    return call;
}

+ (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
                                  handler:(FBDialogAppCallCompletionHandler)handler {
    return [FBDialogs presentShareDialogWithLink:link
                                            name:nil
                                         caption:nil
                                     description:nil
                                         picture:nil
                                     clientState:nil
                                         handler:handler];
}

+ (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
                                     name:(NSString *)name
                                  handler:(FBDialogAppCallCompletionHandler)handler {
    return [FBDialogs presentShareDialogWithLink:link
                                            name:name
                                         caption:nil
                                     description:nil
                                         picture:nil
                                     clientState:nil
                                         handler:handler];
}

+ (FBAppCall *)presentShareDialogWithLink:(NSURL *)link
                                     name:(NSString *)name
                                  caption:(NSString *)caption
                              description:(NSString *)description
                                  picture:(NSURL *)picture
                              clientState:(NSDictionary *)clientState
                                  handler:(FBDialogAppCallCompletionHandler)handler {
    FBShareDialogParams *params = [[[FBShareDialogParams alloc] init] autorelease];
    params.link = link;
    params.name = name;
    params.caption = caption;
    params.description = description;
    params.picture = picture;

    return [self presentShareDialogWithParams:params
                                  clientState:clientState
                                      handler:handler];
}

+ (BOOL)canPresentShareDialogWithOpenGraphActionParams:(FBOpenGraphActionShareDialogParams *)params {
    BOOL canPresent = [params appBridgeVersion] != nil;
    [FBInsights logImplicitEvent:FBInsightsEventNameFBDialogsCanPresentShareDialogOG
                      valueToSum:1.0
                      parameters:@{ FBInsightsEventParameterDialogOutcome :
                                         canPresent ?
                                            FBInsightsDialogOutcomeValue_Completed :
                                            FBInsightsDialogOutcomeValue_Failed }
                         session:nil];
    return canPresent;
}

+ (FBAppCall *)presentShareDialogWithOpenGraphActionParams:(FBOpenGraphActionShareDialogParams *)params
                                               clientState:(NSDictionary *)clientState
                                                   handler:(FBDialogAppCallCompletionHandler)handler {
    FBAppCall *call = nil;
    NSString *version = [params appBridgeVersion];
    if (version) {
        call = [[[FBAppCall alloc] init] autorelease];

        NSError *validationError = [params validate];
        if (validationError) {
            if (handler) {
                handler(call, nil, validationError);
            }
        } else {
            FBDialogsData *dialogData = [[[FBDialogsData alloc] initWithMethod:@"ogshare"
                                                                      arguments:[params dictionaryMethodArgs]]
                                         autorelease];
            dialogData.clientState = clientState;

            call.dialogData = dialogData;

            [[FBAppBridge sharedInstance] dispatchDialogAppCall:call
                                                        version:version
                                              completionHandler:handler];
        }
    }

    return call;
}

+ (FBAppCall *)presentShareDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
                                          actionType:(NSString *)actionType
                                 previewPropertyName:(NSString *)previewPropertyName
                                             handler:(FBDialogAppCallCompletionHandler) handler {
    return [FBDialogs presentShareDialogWithOpenGraphAction:action
                                                 actionType:actionType
                                        previewPropertyName:previewPropertyName
                                                clientState:nil
                                                    handler:handler];
}

+ (FBAppCall *)presentShareDialogWithOpenGraphAction:(id<FBOpenGraphAction>)action
                                          actionType:(NSString *)actionType
                                 previewPropertyName:(NSString*)previewPropertyName
                                         clientState:(NSDictionary *)clientState
                                             handler:(FBDialogAppCallCompletionHandler) handler {
    FBOpenGraphActionShareDialogParams *params = [[[FBOpenGraphActionShareDialogParams alloc] init] autorelease];

    // If we have OG objects, we want to pass just their URL or id to the share dialog.
    params.action = action;
    params.actionType = actionType;
    params.previewPropertyName = previewPropertyName;

    return [self presentShareDialogWithOpenGraphActionParams:params
                                                 clientState:clientState
                                                     handler:handler];
}

+ (SLComposeViewController*)composeViewControllerWithSession:(FBSession*)session
                                                     handler:(FBOSIntegratedShareDialogHandler)handler {
    // Can we even call the iOS API?
    Class composeViewControllerClass = [SLComposeViewController class];
    if (composeViewControllerClass == nil ||
        [composeViewControllerClass isAvailableForServiceType:SLServiceTypeFacebook] == NO) {
        if (handler) {
            handler( FBOSIntegratedShareDialogResultError, [self createError:FBErrorDialogNotSupported
                                                                     session:session]);
        }
        return nil;
    }

    if (session == nil) {
        // No session provided -- do we have an activeSession? We must either have a session that
        // was authenticated with native auth, or no session at all (in which case the app is
        // running unTOSed and we will rely on the OS to authenticate/TOS the user).
        session = [FBSession activeSession];
    }
    if (session != nil) {
        // If we have an open session and it's not native auth, fail. If the session is
        // not open, attempting to put up the dialog will prompt the user to configure
        // their account.
        if (session.isOpen && session.accessTokenData.loginType != FBSessionLoginTypeSystemAccount) {
            if (handler) {
                handler( FBOSIntegratedShareDialogResultError, [self createError:FBErrorDialogInvalidForSession
                                                                         session:session]);
            }
            return nil;
        }
    }

    SLComposeViewController *composeViewController = [composeViewControllerClass composeViewControllerForServiceType:SLServiceTypeFacebook];
    if (composeViewController == nil) {
        if (handler) {
            handler( FBOSIntegratedShareDialogResultError, [self createError:FBErrorDialogCantBeDisplayed
                                                                     session:session]);
        }
        return nil;
    }
    return composeViewController;
}

+ (NSError *)createError:(NSString *)reason
                 session:(FBSession *)session {
    NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
    userInfo[FBErrorDialogReasonKey] = reason;
    if (session) {
        userInfo[FBErrorSessionKey] = session;
    }
    NSError *error = [NSError errorWithDomain:FacebookSDKDomain
                                         code:FBErrorDialog
                                     userInfo:userInfo];
    return error;
}

@end


text:
layout: article
title: Navigation to Any Page After Click
description: How to perform the navigation to different pages after the button/link click.
---

{{ page.description }}
{:.lead}

## Given

Simple sign in form which after 'Sign In' button click can navigate user to different pages.
For example, to admin page or regular user profile page, depending on user account.

{% capture html %}

    Email
    <input type="email" class="form-control" id="email">

    Password
    <input type="password" class="form-control" id="password">

<button class="btn btn-primary">Sign In</button>

{% endcapture %}

{% include htmlexample.html html=html %}

## Implementation

```cs
using Atata;

namespace SampleApp.UITests
{
    using _ = SignInPage;

    public class SignInPage : Page<_>
    {
        public TextInput<_> Email { get; private set; }

        public PasswordInput<_> Password { get; private set; }

        public Button<_> SignIn { get; private set; }
    }
}
```
{:.page-object}

### Navigate to Regular User Profile Page

```cs
Go.To<SignInPage>().
    Email.Set("user@mail.com").
    Password.Set("abc123").
    SignIn.ClickAndGo<UserProfilePage>();
```
{:.test}

### Navigate to Admin Page

```cs
Go.To<SignInPage>().
    Email.Set("admin@mail.com").
    Password.Set("abc123").
    SignIn.ClickAndGo<AdminPage>();
```
{:.test}


text:
package org.apache.jackrabbit.oak.query;

import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty;

import java.util.List;

import javax.jcr.PropertyType;

import org.apache.jackrabbit.mk.json.JsopReader;
import org.apache.jackrabbit.mk.json.JsopTokenizer;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.kernel.TypeCodes;
import org.apache.jackrabbit.oak.plugins.memory.BooleanPropertyState;
import org.apache.jackrabbit.oak.plugins.memory.StringPropertyState;
import org.apache.jackrabbit.oak.plugins.value.Conversions;

import com.google.common.collect.Lists;

/**
 * Utility class for working with jsop string diffs
 *
 */
public class JsopUtil {

    private JsopUtil() {

    }

    /**
     * Applies the commit string to a given Root instance
     *
     *
     * The commit string represents a sequence of operations, jsonp style:
     *
     *

     * / + "test": { "a": { "id": "ref:123" }, "b": { "id" : "str:123" }}
     *

     * or
     *

     * "/ - "test"
     *

     *
     * @param root
     * @param commit the commit string
     * @throws UnsupportedOperationException if the operation is not supported
     */
    public static void apply(Root root, String commit)
            throws UnsupportedOperationException {
        int index = commit.indexOf(' ');
        String path = commit.substring(0, index).trim();
        Tree c = root.getTree(path);
        if (c == null) {
            // TODO create intermediary?
            throw new UnsupportedOperationException("Non existing path " + path);
        }
        commit = commit.substring(index);
        JsopTokenizer tokenizer = new JsopTokenizer(commit);
        if (tokenizer.matches('-')) {
            removeTree(c, tokenizer);
        } else if (tokenizer.matches('+')) {
            addTree(c, tokenizer);
        } else {
            throw new UnsupportedOperationException(
                    "Unsupported " + (char) tokenizer.read() +
                    ". This should be either '+' or '-'.");
        }
    }

    private static void removeTree(Tree t, JsopTokenizer tokenizer) {
        String path = tokenizer.readString();
        for (String p : PathUtils.elements(path)) {
            if (!t.hasChild(p)) {
                return;
            }
            t = t.getChild(p);
        }
        t.remove();
    }

    private static void addTree(Tree t, JsopTokenizer tokenizer) {
        do {
            String key = tokenizer.readString();
            tokenizer.read(':');
            if (tokenizer.matches('{')) {
                Tree c = t.addChild(key);
                if (!tokenizer.matches('}')) {
                    addTree(c, tokenizer);
                    tokenizer.read('}');
                }
            } else if (tokenizer.matches('[')) {
                t.setProperty(readArrayProperty(key, tokenizer));
            } else {
                t.setProperty(readProperty(key, tokenizer));
            }
        } while (tokenizer.matches(','));
    }

    /**
     * Read a {@code PropertyState} from a {@link JsopReader}
     * @param name  The name of the property state
     * @param reader  The reader
     * @return new property state
     */
    private static PropertyState readProperty(String name, JsopReader reader) {
        if (reader.matches(JsopReader.NUMBER)) {
            String number = reader.getToken();
            return createProperty(name, number, PropertyType.LONG);
        } else if (reader.matches(JsopReader.TRUE)) {
            return BooleanPropertyState.booleanProperty(name, true);
        } else if (reader.matches(JsopReader.FALSE)) {
            return BooleanPropertyState.booleanProperty(name, false);
        } else if (reader.matches(JsopReader.STRING)) {
            String jsonString = reader.getToken();
            int split = TypeCodes.split(jsonString);
            if (split != -1) {
                int type = TypeCodes.decodeType(split, jsonString);
                String value = TypeCodes.decodeName(split, jsonString);
                if (type == PropertyType.BINARY) {
                    throw new UnsupportedOperationException();
                } else {
                    return createProperty(name, value, type);
                }
            } else {
                return StringPropertyState.stringProperty(name, jsonString);
            }
        } else {
            throw new IllegalArgumentException("Unexpected token: " + reader.getToken());
        }
    }

    /**
     * Read a multi valued {@code PropertyState} from a {@link JsopReader}
     * @param name  The name of the property state
     * @param reader  The reader
     * @return new property state
     */
    private static PropertyState readArrayProperty(String name, JsopReader reader) {
        int type = PropertyType.STRING;
        List<Object> values = Lists.newArrayList();
        while (!reader.matches(']')) {
            if (reader.matches(JsopReader.NUMBER)) {
                String number = reader.getToken();
                type = PropertyType.LONG;
                values.add(Conversions.convert(number).toLong());
            } else if (reader.matches(JsopReader.TRUE)) {
                type = PropertyType.BOOLEAN;
                values.add(true);
            } else if (reader.matches(JsopReader.FALSE)) {
                type = PropertyType.BOOLEAN;
                values.add(false);
            } else if (reader.matches(JsopReader.STRING)) {
                String jsonString = reader.getToken();
                int split = TypeCodes.split(jsonString);
                if (split != -1) {
                    type = TypeCodes.decodeType(split, jsonString);
                    String value = TypeCodes.decodeName(split, jsonString);
                    if (type == PropertyType.BINARY) {
                        throw new UnsupportedOperationException();
                    } else if (type == PropertyType.DOUBLE) {
                        values.add(Conversions.convert(value).toDouble());
                    } else if (type == PropertyType.DECIMAL) {
                        values.add(Conversions.convert(value).toDecimal());
                    } else {
                        values.add(value);
                    }
                } else {
                    type = PropertyType.STRING;
                    values.add(jsonString);
                }
            } else {
                throw new IllegalArgumentException("Unexpected token: " + reader.getToken());
            }
            reader.matches(',');
        }
        return createProperty(name, values, Type.fromTag(type, true));
    }

}


text:
using System;

namespace ToolGood.ReadyGo3.Attributes
{
    /// <summary>
    /// 非空标签
    /// </summary>
    public class RequiredAttribute : Attribute
    {
        /// <summary>
        /// 是否非空
        /// </summary>
        public bool Required;
        /// <summary>
        /// 非空标签
        /// </summary>
        /// <param name="required"></param>
        public RequiredAttribute(bool required = true)
        {
            Required = required;
        }
    }
}