我正在尝试解析博客文章a主要部分 ( <article>) 中的链接。我已经改编了我在FPComplete 上找到的内容,但没有打印出任何内容。(就我所见,该代码在在线 IDE 上运行时不起作用,并且 Bing 目标也不会产生任何链接。)
在 GHCI 中,我可以模拟 parseAF 的第一行,这让我得到了一个大记录,我认为这是正确的。但cursor $// findNodes &| extractData返回[]
我试过正则表达式,但试图找到这么长的一段文字并不高兴。
任何人都可以帮忙吗?
{-# LANGUAGE OverloadedStrings #-}
module HtmlParser where
import Network.HTTP.Conduit (simpleHttp)
import Prelude hiding (concat, putStrLn)
import Data.Text (concat)
import Data.Text.IO (putStrLn)
import Text.HTML.DOM (parseLBS)
import Text.XML.Cursor (Cursor, attribute, element, fromDocument, ($//), (&//), (&/), (&|))
-- The URL we're going to search
url = "http://www.amsterdamfoodie.nl/2015/wine-beer-food-restaurants-troost/"
-- The data we're going to search for …Run Code Online (Sandbox Code Playgroud) 任何人都可以帮助我担心的一个愚蠢的错误.考虑这两个片段:
defmodule MosaicApi.Repo.Migrations.CreateCard do
use Ecto.Migration
def change do
create table(:cards) do
add :creation_date, :date
Run Code Online (Sandbox Code Playgroud)
和
defmodule MosaicApi.Card do
use MosaicApi.Web, :model
schema "cards" do
field :creation_date, Ecto.Date
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用一些数据
cards = [
%Card{
creation_date: "2014-04-17",
Run Code Online (Sandbox Code Playgroud)
我从互联网上找到的东西中得到了这些简单的字符串; 替代似乎是{"2015","04","17"}.
**(Ecto.ChangeError)值
"2014-04-17"用于MosaicApi.Card.creation_date在insert不匹配类型Ecto.Date
我想设置 Phoenix 为静态 index.html 提供服务,无论发送给它的路由是什么,而无需更改 URL,同时提供对非 html 资产(.js、.css、.jpg、...)的访问,因为我的SPA(在榆树中)会查看路线并确定要做什么。
端点.ex
plug Plug.Static,
at: "/", from: :mosaic_api, gzip: false,
only: ~w(assets css fonts images js favicon.ico robots.txt index.html)
Run Code Online (Sandbox Code Playgroud)
路由器文件
scope "/", Api do
pipe_through :browser # Use the default browser stack
get "/*path", PageController, :index # :elm
end
Run Code Online (Sandbox Code Playgroud)
页面控制器
defmodule Api.PageController do
use Api.Web, :controller
plug :action # Edit: now removed
def index(conn, _params) do
conn
|> put_layout(false)
|> render("index.html")
# Edit: replaced 3 lines …Run Code Online (Sandbox Code Playgroud) 我对 Vue 完全陌生。
我想使用 CLI 并且我想要有 4 个空格缩进(使用 typescript 和 vuex)。但是经过 24 小时的挣扎,我离让任何事情都变得更近了。如果这是不可能的,也请告诉我。
我认为 tslint 是要走的路,但找不到解决方案。所以我尝试了 eslint 并将其添加到 package.json
"devDependencies": {
"@vue/cli-plugin-eslint": "^3.0.4",
"@vue/cli-plugin-pwa": "^3.0.4",
"@vue/cli-plugin-typescript": "^3.0.4",
"@vue/cli-service": "^3.0.4",
"@vue/eslint-config-prettier": "^3.0.4",
"@vue/eslint-config-typescript": "^3.0.4",
"eslint": "^5.6.1",
"eslint-plugin-vue": "^5.0.0-beta.3", // <------------------
"typescript": "^3.0.0",
"vue-template-compiler": "^2.5.17"
}
Run Code Online (Sandbox Code Playgroud)
然后是 eslintrc 我有
module.exports = {
root: true,
env: {
node: true
},
extends: ["plugin:vue/essential", "@vue/prettier", "@vue/typescript"],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
"vue/script-indent": …Run Code Online (Sandbox Code Playgroud) 这应该是最简单的嵌套组件,但是当我加载它(通过systemjs)时,我在浏览器中看到的所有内容都是"计数器",并且<counter></counter>已经添加到DOM中.没有"Hello Counter"或counter组件处理的迹象.
import angular from 'angular2/angular2';
var AppComponent = angular
.Component({
selector: 'my-app',
template: '<h1>Counters</h1><counter></counter>'
})
.Class({
constructor: function () { }
});
angular
.Component({
selector: 'counter',
template: '<h2>Hello counter</h2>'
})
.Class({
constructor: function () {}
});
angular.bootstrap(AppComponent);
Run Code Online (Sandbox Code Playgroud) 备注站点有一个指向 AST 浏览器的链接,用于备注输出 - https://astexplorer.net/#/gist/0a92bbf654aca4fdfb3f139254cf0bad/ffe102014c188434c027e43661dbe6ec30042ee2
我找不到的是如何解析 AST - 所有示例都转换为 HTML。
我有这个代码
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkGfm from 'remark-gfm' // git flavoured markdown
const content = `
# My header
This is my content
- abc
- def
`;
unified()
.use(remarkParse)
.use(remarkGfm)
.process('# Hi\n\n*Hello*, world!')
.then((file) => {
console.log(String(file))
})
Run Code Online (Sandbox Code Playgroud)
但我在这里遇到了一些错误,我不知道如何解决
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkGfm from 'remark-gfm' // git flavoured markdown
const content = `
# My header …Run Code Online (Sandbox Code Playgroud) [我的问题与建议的重复问题不同,因为我的动画 div 中存在填充]
尝试让 div 展开,没有固定的高度和一些填充。我的 css 如下,我.closed使用 jquery 切换。
.slide {
padding: 10%;
background-color: gold;
overflow-y: hidden;
transition: height 2s;
transition: max-height 2s;
height: auto;
max-height: 1000px;
}
.closed {
height: 0;
max-height: 0;
}
Run Code Online (Sandbox Code Playgroud)
问题是,使用填充,您无法隐藏开始的文本,并且如果没有固定的高度,您将无法获得过渡的 css 更改。任何人都可以帮忙 - 希望我不需要用 javascript 做更多的事情吗?
更新我现在必须:
.slide {
padding: 10%;
background-color: gold;
overflow-y: hidden;
transition: max-height 2s ease;
max-height: 500px;
}
.closed {
max-height: 0;
padding: 0;
transition: all 2s ease;
}
Run Code Online (Sandbox Code Playgroud)
参见plnkr。现在的问题是关闭时的填充。在上面的情况下,它会过渡出来,如果我将 .close 中的过渡限制为max-height那么就会出现不和谐的效果,因为它会在动画开始时崩溃。
我正在尝试创建一个组件列表并附加一个click事件监听器,用于注册所单击组件的索引.
我可以通过在我的叶子节点上附加事件监听器来实现这一点,因为它知道它的索引.但后来我不得不再次冒这个事件了.我更喜欢做的是在叶子的父母处拥有以下内容:
template: `
<trackpoint
*ngFor='#tp of lapData; #i=index'
[tp]='tp'
[index]='i'
[ngClass]="{selected:selectedTps[i]}"
(click)='handleClick($event)'>
</trackpoint>
`,
Run Code Online (Sandbox Code Playgroud)
在我的控制器里
handleClick(e:MouseEvent) {
console.log(e);
this.lapEventHandler.next({
// I want to be able to access i from the template
});
}
Run Code Online (Sandbox Code Playgroud)
我一直在检查MouseEvent对象,但是虽然我可以在事件父项中找到Trackpoint,但我找不到该index属性.我想做不可能的事吗?
我正在查看elm-form包文档,并在这里找到这段代码:
field "myfield" (int `andThen` minInt 10)
Run Code Online (Sandbox Code Playgroud)
这些引用是什么意思?这是应用函数的另一种方式吗?
我有以下简单的消息应用程序
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getMessaging, getToken } from "firebase/messaging";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AI...Y",
authDomain: "xyz.firebaseapp.com",
databaseURL: "https://xyz.firebaseio.com",
projectId: "xyz",
storageBucket: "xyz.appspot.com",
messagingSenderId: "441...38",
appId: "1:....f",
measurementId: "G-...",
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const vapidKey = "BLFWI5-...opE";
console.log("have app");
const messaging = getMessaging(app);
console.log("have messaging", messaging);
getToken({ vapidKey })
.then((res) => console.log("token", res))
.catch((err) …Run Code Online (Sandbox Code Playgroud)